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

field shadowing does not check for object extensibility #51

Open
tilk opened this issue Jan 27, 2015 · 1 comment
Open

field shadowing does not check for object extensibility #51

tilk opened this issue Jan 27, 2015 · 1 comment

Comments

@tilk
Copy link

tilk commented Jan 27, 2015

In the case corresponding to E-ShadowField in the semantics ("A Tested Semantics..."), the object is not checked for extensibility; the check is there in the semantics. The check is also in EcmaScript specification (8.12.4 step 8a).

@jpolitz
Copy link
Member

jpolitz commented Feb 5, 2015

The interpreter does omit this check, thanks!

S5 as a whole passes the related test cases because the 8.12.4 step 8a check is happening in the %set-property function in es5.env: https://github.com/brownplt/LambdaS5/blob/master/envs/es5.env#L1959 (which also does some work in doing the right thing for Array indices, which are another complication here).

So S5 (as a whole) correctly throws an error (assuming strict mode) on, e.g.

var o = {x: 5};
var o2 = Object.create(o);
Object.preventExtensions(o2);
o2.x = 10;
console.log(o2.x);

But the error isn't coming from the semantics, it's coming from some wrapper desugaring code.

That is definitely a check that's in the paper's semantics, and in line with the comment at https://github.com/brownplt/LambdaS5/blob/master/src/ljs/ljs_eval.ml#L73, I think I'd be happier with an extensible check in the interpreter at https://github.com/brownplt/LambdaS5/blob/master/src/ljs/ljs_eval.ml#L288, in the case where the field isn't an own property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants