Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 876accfa73f6d4613d489f23a88b20e827cfbc73
      
https://github.com/WebKit/WebKit/commit/876accfa73f6d4613d489f23a88b20e827cfbc73
  Author: David Degazio <d_dega...@apple.com>
  Date:   2022-11-16 (Wed, 16 Nov 2022)

  Changed paths:
    A JSTests/stress/assignment-side-effects-before-tdz-check.js
    M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

  Log Message:
  -----------
  Evaluate right-hand-side of assignment before TDZ check
https://bugs.webkit.org/show_bug.cgi?id=247787
rdar://102324888

Reviewed by Yusuke Suzuki.

When we assign to a variable in its TDZ, we currently always do a TDZ check
before evaluating anything else. However, per the spec, we should actually
be evaluating the right-hand-side value before putting it into the destination -
potentially resulting in observable side-effects like throwing an exception. 
This
patch makes it so we add a TDZ check only after evaluating the right-hand-side
expression in assignment expressions. We shouldn't need this for any
read-modify-assignment expressions (i.e. +=, &&=) since those are supposed to
read the TDZ-checked value before evaluating the right.

* JSTests/stress/assignment-side-effects-before-tdz-check.js: Added.
(catch):
(try.x):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::AssignResolveNode::emitBytecode):

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


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

Reply via email to