-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Inherit ScopeFlags::StrictMode
from parent scope
#3862
Labels
C-bug
Category - Bug
Comments
NB: #3908 moves the logic above to oxc_semantic/src/scope.rs |
strict mode should be inherited, seems like a bug in places that are not checked. This can be verified by oxc/crates/oxc_semantic/src/checker/javascript.rs Lines 146 to 149 in c26975a
where strictness is checked on the scope. |
ScopeFlags::StrictMode
be set?ScopeFlags::StrictMode
from parent scope
Thanks for clarifying. I think we can fix with:
|
Seems fixed? |
overlookmotel
pushed a commit
that referenced
this issue
Aug 5, 2024
Fixed in #4664. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There appear to be some discrepancies in when
ScopeFlags::StrictMode
is applied by semantic.enter_scope
looks like its logic is thatStrictMode
should be set on any scope which is strict mode (including from a'use strict'
directive somewhere above it). But this doesn't appear to be what it actually does, because it only setsStrictMode
flag if the direct parent is a function with a'use strict'
directive, or if the entire program is strict mode:oxc/crates/oxc_semantic/src/builder.rs
Lines 414 to 440 in 9e148e9
A couple of examples of weirdness:
When is
StrictMode
flag meant to be set?If intended behavior is that
StrictMode
flag should be set for any scope which runs in strict context, we can simplify the above logic to:The text was updated successfully, but these errors were encountered: