Ignore:
Timestamp:
Mar 21, 2022, 12:57:19 PM (3 years ago)
Author:
[email protected]
Message:

[JSC] ReferenceError when using extra parens in class fields
https://bugs.webkit.org/show_bug.cgi?id=236843

Reviewed by Saam Barati.

JSTests:

  • stress/class-field-initializer-should-have-variable-scope.js: Added.

(shouldBe):
(test1.const.a.x.B):
(test1):
(test2.const.a.x.B):
(test2):
(test3.B.prototype.b):
(test3.B):
(test3):

Source/JavaScriptCore:

class field initializer should create its own used-variables set
to capture used variables separately from the other variables since
it becomes independent CodeBlock internally later. The current code
was wrong since,

  1. Incorrectly using the current set of class-scope.
  2. Incorrectly marking only the last set while parseAssignmentExpression can create a new set inside it.
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseClass):

  • parser/Parser.h:

(JSC::Scope::markLastUsedVariablesSetAsCaptured):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r288473 r291577  
    664664    }
    665665
    666     void markLastUsedVariablesSetAsCaptured()
    667     {
    668         for (UniquedStringImpl* impl : m_usedVariables.last())
    669             m_closedVariableCandidates.add(impl);
     666    void markLastUsedVariablesSetAsCaptured(unsigned from)
     667    {
     668        for (unsigned index = from; index < m_usedVariables.size(); ++index) {
     669            for (UniquedStringImpl* impl : m_usedVariables[index])
     670                m_closedVariableCandidates.add(impl);
     671        }
    670672    }
    671673   
Note: See TracChangeset for help on using the changeset viewer.