Skip to content

Commit 693a1b4

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 a050cfa commit 693a1b4

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
@@ -8329,9 +8329,10 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
83298329
}
83308330
});
83318331

8332-
// Check whether we have already established an initializer context.
8332+
// Check whether we have already established an initializer context for
8333+
// the first binding entry (subsequent entries need a separate context).
83338334
PatternBindingInitializer *initContext =
8334-
findAttributeInitContent(Attributes);
8335+
PBDEntries.empty() ? findAttributeInitContent(Attributes) : nullptr;
83358336

83368337
// Remember this pattern/init pair for our ultimate PatternBindingDecl. The
83378338
// 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)