-
-
Notifications
You must be signed in to change notification settings - Fork 133
eval: SyntaxError for new.target in direct eval outside non-arrow function (#5579) #5766
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,8 @@ fn lower_method_prop( | |
| .collect(); | ||
|
|
||
| let scope_mark = ctx.enter_scope(); | ||
| let saved_in_nonarrow_fn = ctx.in_nonarrow_fn; | ||
| ctx.in_nonarrow_fn = true; | ||
| // Object-literal methods are NOT implicitly strict (unlike class bodies): | ||
| // strictness is inherited from the enclosing code or introduced by the | ||
| // method's own directive prologue. A blanket `true` here made every | ||
|
|
@@ -343,6 +345,7 @@ fn lower_method_prop( | |
| } | ||
| ctx.exit_strict_mode(); | ||
| ctx.exit_scope(scope_mark); | ||
| ctx.in_nonarrow_fn = saved_in_nonarrow_fn; | ||
|
|
||
| // Capture analysis (same pattern as arrow/function expressions) | ||
| let mut all_refs = Vec::new(); | ||
|
|
@@ -465,6 +468,8 @@ fn lower_accessor_prop( | |
| .collect(); | ||
|
|
||
| let scope_mark = ctx.enter_scope(); | ||
| let saved_in_nonarrow_fn = ctx.in_nonarrow_fn; | ||
| ctx.in_nonarrow_fn = true; | ||
|
Comment on lines
+471
to
+472
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Restore The bailout at Line 486 unwinds strict mode and scope, but leaves Suggested fix Err(_) => {
ctx.exit_strict_mode();
ctx.exit_scope(scope_mark);
+ ctx.in_nonarrow_fn = saved_in_nonarrow_fn;
return Ok(None);
}Also applies to: 486-489 🤖 Prompt for AI Agents |
||
| // Accessors in object literals inherit strictness (see lower_method_prop). | ||
| let accessor_strict = ctx.current_strict_mode() | ||
| || body | ||
|
|
@@ -508,6 +513,7 @@ fn lower_accessor_prop( | |
| }; | ||
| ctx.exit_strict_mode(); | ||
| ctx.exit_scope(scope_mark); | ||
| ctx.in_nonarrow_fn = saved_in_nonarrow_fn; | ||
|
|
||
| // Capture analysis — identical pattern to `lower_method_prop`. | ||
| let mut all_refs = Vec::new(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 24930
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 5820
Restore
in_nonarrow_fnon the earlyOk(None)return Incrates/perry-hir/src/lower/expr_object.rs:485-490, the setter bailout skipsctx.in_nonarrow_fn = saved_in_nonarrow_fn;, so a malformed setter param can leaktrueinto later lowering and misclassify subsequentnew.target/evalchecks.🤖 Prompt for AI Agents