Skip to content

Commit 2dff3f1

Browse files
pgorszkowski-igalialauromoura
authored andcommitted
REGRESSION(324783@main): [JSC] Build fails with clang 20: "unnamed variable cannot be implicitly captured in a lambda expression" in LiteralParser.cpp
https://bugs.webkit.org/show_bug.cgi?id=329046 Reviewed by Carlos Alberto Lopez Perez. Since 324783@main, clang 20 fails to compile LiteralParser.cpp: error: unnamed variable cannot be implicitly captured in a lambda expression The in-class declaration of LiteralParser::parseRecursively() leaves its VM& parameter unnamed, while the out-of-line definition names it `vm` and has a trailing requires-clause. When a lambda inside the definition implicitly captures `vm` with [&], clang 20 resolves the capture to the parameter of the unnamed declaration and rejects it. Before 324783@main this was avoided by capturing `vm` explicitly with `&vm = vm`, but that change replaced those captures with plain [&] and added new lambdas that use `vm`. Capture `vm` explicitly again in the parseValue, putWithTransition and property lambdas, which are the ones in parseRecursively() that use it. * Source/JavaScriptCore/runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType, reviverMode>::parseRecursively): Canonical link: https://commits.webkit.org/324843@main
1 parent 45f193a commit 2dff3f1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎Source/JavaScriptCore/runtime/LiteralParser.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ JSValue LiteralParser<CharType, reviverMode>::parseRecursively(VM& vm, uint8_t*
16431643

16441644
// Dispatching on the first character skips the generic token dispatch that
16451645
// parsePrimitiveValue would otherwise repeat on the token type.
1646-
auto parseValue = [&](bool lookUpCachedStrings) ALWAYS_INLINE_LAMBDA -> JSValue {
1646+
auto parseValue = [&, &vm = vm](bool lookUpCachedStrings) ALWAYS_INLINE_LAMBDA -> JSValue {
16471647
UNUSED_PARAM(lookUpCachedStrings);
16481648
switch (m_lexer.peek()) {
16491649
case '"': {
@@ -1686,7 +1686,7 @@ JSValue LiteralParser<CharType, reviverMode>::parseRecursively(VM& vm, uint8_t*
16861686

16871687
// Objects from JSON are JSFinalObjects that rarely have duplicate keys and usually share an existing
16881688
// Structure, so adding a property is a store plus a StructureID swap with no generic put machinery.
1689-
auto putWithTransition = [&](StructureID originalStructureID, StructureID newStructureID, PropertyOffset offset, JSValue value) ALWAYS_INLINE_LAMBDA {
1689+
auto putWithTransition = [&, &vm = vm](StructureID originalStructureID, StructureID newStructureID, PropertyOffset offset, JSValue value) ALWAYS_INLINE_LAMBDA {
16901690
ASSERT(object->structureID() == originalStructureID);
16911691
Structure* originalStructure = originalStructureID.decode();
16921692
Structure* newStructure = newStructureID.decode();
@@ -1860,7 +1860,7 @@ JSValue LiteralParser<CharType, reviverMode>::parseRecursively(VM& vm, uint8_t*
18601860

18611861
ASSERT(object->structure() == structure);
18621862
auto* originalStructure = structure;
1863-
auto property = [&] ALWAYS_INLINE_LAMBDA -> Variant<ExistingProperty, Identifier> {
1863+
auto property = [&, &vm = vm] ALWAYS_INLINE_LAMBDA -> Variant<ExistingProperty, Identifier> {
18641864
if (consumedProperty)
18651865
return *consumedProperty;
18661866
if (Structure* transition = originalStructure->trySingleTransition()) {

0 commit comments

Comments
 (0)