Replies: 1 comment
-
The Mixing such general table types with records is often a sign of something tricky going on. When such use of the table is read-only, of course things are safe, but often we're using So, right now the alternative to do such general-table manipulation on record is really to do In my experience, this has been a good thing: when I'm hunting my own bugs in Teal, the presence of |
Beta Was this translation helpful? Give feedback.
-
table
is an alias for{any:any}
based on this test case: https://github.com/teal-language/tl/blob/master/spec/subtyping/table_spec.lua#L3. I assumed thatrecord
is a subtype oftable
, allowing me to pass in any record,{any}
, and{any:any}
. If it's relevant, my use case is that I want to accept any value that could have a metatable.Fails with:
If it's desirable to distinguish between records and tables, then if there was a type like
record
that accepts any record, then I suppose I could dotable | record
.Beta Was this translation helpful? Give feedback.
All reactions