aardappel / lobster

The Lobster Programming Language
http://strlen.com/lobster
2.24k stars 121 forks source link

"is" type test not usable with structs. #244

Closed MortimerSnerd closed 1 year ago

MortimerSnerd commented 1 year ago

Mentioned this on the forum.

When doing a static type test with is, you get this error if the value is a struct type:

reprep.lobster(4): error: struct value cannot be used in `is` in reprep.lobster(10): do_something(a:xyz_f)->unknown { }

Example code:

import vec

def do_something(a):
   if a is string:
      return "\"{a}\""
   else:
      return string(a)

print(do_something("asds"))
print(do_something(xyz_0))

Not a high priority, I only ever noticed it when cleaning up a return value for a source file meant for run_compile_file().

aardappel commented 1 year ago

Fixed: https://github.com/aardappel/lobster/commit/e0636214d54a1ded59c5cf8514164be65a855f6c