Bug 251760

Summary: Functions are lexically scoped inside static blocks where variable declarations are allowed, ASSERT_WITH_MESSAGE(!m_declaredVariables.size(), "...");
Product: WebKit Reporter: Corban Amouzou <c0dineDev>
Component: JavaScriptCoreAssignee: Yijia Huang <yijia_huang>
Status: RESOLVED FIXED    
Severity: Trivial CC: mark.lam, webkit-bug-importer, yijia_huang, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: All   
OS: All   

Description Corban Amouzou 2023-02-05 11:48:11 PST
In Source/JavaScriptCore/parser/Parser.h we hit the assertion: ASSERT_WITH_MESSAGE(!m_declaredVariables.size(), "...");

This is triggered by a simple case where a class function is declared inside of a static scope:

class A {
  static {
    var B;
    function C() {}
  }
}

What's interesting is that I would assume the variables inside that block would be scoped to that class statically, IE the variable B would be accessible through A.B, but that simply is not the case.
It's not a pressing concern, but it seems like a possible regression of https://bugs.webkit.org/show_bug.cgi?id=168844
Comment 1 Radar WebKit Bug Importer 2023-02-06 16:29:15 PST
<rdar://problem/105104494>
Comment 2 Yijia Huang 2023-02-06 18:05:01 PST
Pull request: https://github.com/WebKit/WebKit/pull/9729
Comment 3 EWS 2023-02-07 13:44:16 PST
Committed 259981@main (b9e63fd65e32): <https://commits.webkit.org/259981@main>

Reviewed commits have been landed. Closing PR #9729 and removing active labels.