Skip to content

Commit 806beef

Browse files
committed
[Parse] Avoid re-using attribute context for non-first entry
This could result in us changing the binding index after-the-fact.
1 parent 5e658fd commit 806beef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8317,9 +8317,10 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
83178317
}
83188318
});
83198319

8320-
// Check whether we have already established an initializer context.
8320+
// Check whether we have already established an initializer context for
8321+
// the first binding entry (subsequent entries need a separate context).
83218322
PatternBindingInitializer *initContext =
8322-
findAttributeInitContent(Attributes);
8323+
PBDEntries.empty() ? findAttributeInitContent(Attributes) : nullptr;
83238324

83248325
// Remember this pattern/init pair for our ultimate PatternBindingDecl. The
83258326
// Initializer will be added later when/if it is parsed.

test/decl/var/property_wrappers.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ struct MultipleWrappers {
253253

254254
@WrapperWithInitialValue // expected-error 2{{property wrapper can only apply to a single variable}}
255255
var (y, z) = (1, 2)
256+
257+
@Clamping(min: 0, max: 255) // expected-error 2{{property wrapper can only apply to a single variable}}
258+
var a = 0, b = 0
256259
}
257260

258261
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)