Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c228e7cdd6379c257cdcfe651bb492b9eadb816b
      
https://github.com/WebKit/WebKit/commit/c228e7cdd6379c257cdcfe651bb492b9eadb816b
  Author: Yijia Huang <yijia_hu...@apple.com>
  Date:   2022-11-11 (Fri, 11 Nov 2022)

  Changed paths:
    A JSTests/stress/destructuring-for-in-of.js
    M Source/JavaScriptCore/parser/Parser.cpp

  Log Message:
  -----------
  TypeError is expected when reassigning to `const` during destructuring in for 
statement
https://bugs.webkit.org/show_bug.cgi?id=247432
rdar://102064568

Reviewed by Yusuke Suzuki.

Running this JavaScript program should throw TypeError.
```
class x { static #y = { x = 0 } = 0 ; }
```

V8
```
class x { static #y = { x = 0 } = 0 ; }
                        ^
TypeError: Assignment to constant variable.
```

GraalJS
```
TypeError: Assignment to constant "x"
```

To fix this, we should use AssignmentContext::AssignmentExpression
to construct destructuring pattern in for...in/of statement. In this case,
symbolTablePut will check for read-only variable without ignoring.

* JSTests/stress/destructuring-for-in-of.js: Added.
(shouldThrow):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseForStatement):

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to