Closed JoeStrout closed 8 months ago
...While we're at it, think about what we should do if some confused user does new string
, new list
, or new funcRef
. Unless they're just poking the edges of the language on purpose, this is almost certainly an error.
Would be good to throw informative error, akin to
new string
- \new array
- \
Right now you can do
new "foo"
ornew 42
ornew null
, and you get back a map with__isa
set to the argument. But this is a weird map that does not have access to the standard map methods; and doingisa
tests on this produces inconsistent results between the C# and C++ implementations. The resulting beast is just plain weird (and even weirder if you used a funcRef or NaN as your argument!), and it's difficult to decide how it ought to behave, or why you would ever have a valid use for it.So, let's just throw a runtime error if you use
new
with any argument that is not a map. If you manually assign to__isa
, well, we probably can't stop you (without impacting all map-entry assignments) — but we should explicitly document that the resulting behavior is undefined.