Incorrect prototype handling
Opened this issue · 1 comments
SeeSpring commented
let a = {a:0}
let b = {get a(){return 0}}
let c = Math.random() ? a : b
let d = {}
Object.setPrototypeOf(d, c)
let e = ''
if ('a' in d) {
e = 0
}
e.toUpperCase()
Throws Uncaught TypeError: e.toUpperCase is not a function
at runtime
kaleidawave commented
Yes there seems to be some issues with https://kaleidawave.github.io/ezno/playground/?id=klnuy
has_property
could do better on unions or condition results (in the case of the value assigned toc
). The currently do not look at both sides and figure a result. (the firstprint_type("a" in c);
should betrue
)- It seems that the
setPrototypeOf
does not register the prototype when the prototype is a conditional type. It works forsetPrototypeOf(d, a)
andsetPrototypeOf(d, b)
but not withc
. Once the property access works and returns a result, then"a" in d
should returntrue
(rather thanfalse
and the example above should work 🤞)