-
|
I'm a bit lost in this problem, here's an example: local record Foo
type X = {string, number, boolean} -- tuple structure, so I can init with {'a', 1, true}
record Y
-- without this we get "cannot discriminate a union between multiple table types: X | Y" (fair!)
where type(self.z) == 'number'
z: number
end
type A = X | Y --> cannot mix table types with and without __is metamethod: X | Y
-- so.. how could we add __is to X? I tried record X is {string, number, boolean}, but that's not allowed
endFor now, I'll see if I can do other data-strucutre |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think the easiest way would be to extend the language to allow this. Now that instead of For maps, there's a conflict between string keys and record field names; that would take extra logic to check for conflicts. |
Beta Was this translation helpful? Give feedback.
I think the easiest way would be to extend the language to allow this.
Now that instead of
arrayrecordtypes we have the array type as an interface of the record, implementing this should be easier too. (There might still be some special-casing left in the compiler for records-as-arrays but it's way less "special" than before).For maps, there's a conflict between string keys and record field names; that would take extra logic to check for conflicts.