kaleidawave/ezno

Incorrect prototype handling

Opened this issue · 1 comments

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

Yes there seems to be some issues with https://kaleidawave.github.io/ezno/playground/?id=klnuy

  1. has_property could do better on unions or condition results (in the case of the value assigned to c). The currently do not look at both sides and figure a result. (the first print_type("a" in c); should be true)
  2. It seems that the setPrototypeOf does not register the prototype when the prototype is a conditional type. It works for setPrototypeOf(d, a) and setPrototypeOf(d, b) but not with c. Once the property access works and returns a result, then "a" in d should return true (rather than false and the example above should work 🤞)