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

throw TypeError in strict mode if set trap doesn't return true #10

Open
samthor opened this issue Mar 27, 2016 · 3 comments
Open

throw TypeError in strict mode if set trap doesn't return true #10

samthor opened this issue Mar 27, 2016 · 3 comments

Comments

@samthor
Copy link
Contributor

samthor commented Mar 27, 2016

See MDN.

This code will work inside the calling code, but that's not really what we want:

let strictMode = (function() { return !this; })();

For eager contributors: I want to point out that we need to work out whether the caller is in strict mode (not the proxy code itself). This is possible under some very limited circumstances, but not always. I suspect this issue is unsolvable.

@Nathan-Schwartz
Copy link

I can give it a shot. I plan to use the same strictMode check that @samthor posted. I am not aware of any edge cases where it would fail, but I could be mistaken.

I noticed that the specs don't seem to define a specific TypeError message for this case. Any preference there? I'm imagining something along the lines of 'handler.set: Assignment failed in strict mode'.

@samthor
Copy link
Contributor Author

samthor commented Oct 17, 2019

Working out whether the caller is in strict mode is never going to happen.

I'd probably add an option to the polyfill constructor to run in strict mode, to throw an Error if there's a problem.

This was referenced Jun 21, 2020
@GoogleChrome GoogleChrome deleted a comment from studentIvan Jun 22, 2020
@ExE-Boss
Copy link
Contributor

ExE-Boss commented Jul 1, 2020

There’s a possible way to do this using setter.caller, which throws or returns null if the caller is strict mode code or an async or generator function.


See https://github.com/claudepache/es-legacy-function-reflection/blob/master/analysis.md#value-returned-by-caller-per-type-of-the-purported-caller

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

Successfully merging a pull request may close this issue.

3 participants