Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsound conditional property #208

Open
SeeSpring opened this issue Sep 10, 2024 · 1 comment
Open

Unsound conditional property #208

SeeSpring opened this issue Sep 10, 2024 · 1 comment
Assignees
Labels
bug Something isn't working checking Issues around checking

Comments

@SeeSpring
Copy link

let d = {}
let e = 0
if (Math.random()===0) {d.a = 0}
if ('a' in d) {
  e = ""
}
e.toUpperCase()

Throws Uncaught TypeError: e.toUpperCase is not a function at runtime

@kaleidawave kaleidawave added bug Something isn't working checking Issues around checking labels Sep 14, 2024
@kaleidawave kaleidawave self-assigned this Sep 14, 2024
@kaleidawave
Copy link
Owner

I see, the problem is when combining properties from conditional contexts. Instead of zipping them together and taking into account conditions, it just overrides them. So it thinks that the object always has an a property: https://kaleidawave.github.io/ezno/playground/?id=9zldu

The code to improve is here

// TODO temp fix for `... ? { ... } : { ... }`. Breaks for the fact that property
// properties might be targeting something above the current condition (e.g. `x ? (y.a = 2) : false`);
onto.current_properties.extend(truthy.current_properties.drain());
if let Some(ref mut otherwise) = otherwise {
onto.current_properties.extend(otherwise.current_properties.drain());
}

It shouldn't be too hard to fix. Will take a look at fixing this in #187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working checking Issues around checking
Projects
None yet
Development

No branches or pull requests

2 participants