Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a6b9795636a4a1b2c984c2eb3de3be25b4a2cf55
      
https://github.com/WebKit/WebKit/commit/a6b9795636a4a1b2c984c2eb3de3be25b4a2cf55
  Author: Alexey Shvayka <[email protected]>
  Date:   2023-06-20 (Tue, 20 Jun 2023)

  Changed paths:
    A JSTests/stress/eval-func-decl-in-eval-within-catch-scope.js
    M JSTests/test262/expectations.yaml
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
    M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
    M Source/JavaScriptCore/runtime/JSScope.cpp
    M Source/JavaScriptCore/runtime/JSScope.h
    M Source/JavaScriptCore/runtime/SymbolTable.h

  Log Message:
  -----------
  [JSC] JSScope::resolveScopeForHoistingFuncDeclInEval() should skip simple 
parameter catch scopes
https://bugs.webkit.org/show_bug.cgi?id=258049
<rdar://problem/110737558>

Reviewed by Yusuke Suzuki.

Annex B 3.4 [1] loosens early error rules for a variable name clashing with a 
simple parameter of
outer catch scope, including top-level function declarations in eval().

This change implements only a part of the section [1], in particular precluding 
a SyntaxError from
being thrown when a top-level function declaration in eval() clashes with a 
simple parameter of
outer catch scope (that is the first modification of 
EvalDeclarationInstantiation).

To accomplish that, while still throwing an error for e.g. `catch ({x}) { 
eval("function x() {}") }`,
this patch introduces a new type of scope, while ensuring all the other code 
checks for both
catch scopes types, behaving identically.

While this change aligns JSC with the spec and other runtimes by not throwing a 
SyntaxError, both
top-level and block-level function declarations aren't being hoisted correctly 
from eval() if there
is an outer catch scope with identically named simple parameter, which will be 
fixed in a follow-up.

[1]: https://tc39.es/ecma262/#sec-variablestatements-in-catch-blocks

* JSTests/stress/eval-func-decl-in-eval-within-catch-scope.js: Added.
* JSTests/test262/expectations.yaml: Mark 1 test case as passing.
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::pushLexicalScopeInternal):
(JSC::BytecodeGenerator::emitPushCatchScope):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::TryNode::emitBytecode):
* Source/JavaScriptCore/runtime/JSScope.cpp:
(JSC::JSScope::collectClosureVariablesUnderTDZ):
(JSC::JSScope::resolveScopeForHoistingFuncDeclInEval):
(JSC::JSScope::isCatchScope):
(JSC::JSScope::isCatchScopeWithSimpleParameter):
* Source/JavaScriptCore/runtime/JSScope.h:
* Source/JavaScriptCore/runtime/SymbolTable.h:

Canonical link: https://commits.webkit.org/265331@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to