Skip to content

Commit 47a254b

Browse files
committed
[Sema] fix typevar attr for subscript
1 parent 5b773fc commit 47a254b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,8 @@ namespace {
10601060

10611061
// Add the member constraint for a subscript declaration.
10621062
// FIXME: weak name!
1063-
auto memberTy = CS.createTypeVariable(memberLocator, TVO_CanBindToNoEscape);
1063+
auto memberTy = CS.createTypeVariable(
1064+
memberLocator, TVO_CanBindToLValue | TVO_CanBindToNoEscape);
10641065

10651066
// FIXME: synthesizeMaterializeForSet() wants to statically dispatch to
10661067
// a known subscript here. This might be cleaner if we split off a new

test/attr/attr_dynamic_member_lookup.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ struct WithTrailingClosure {
619619

620620
func keypath_with_trailing_closure_subscript(_ ty: inout SubscriptLens<WithTrailingClosure>) {
621621
_ = ty[0] { 42 } // expected-error {{subscript index of type '() -> Int' in a key path must be Hashable}}
622-
_ = ty[0] { 42 } = 0
622+
_ = ty[0] { 42 } = 0 // expected-error {{cannot assign through subscript: subscript is get-only}}
623623
// expected-error@-1 {{subscript index of type '() -> Int' in a key path must be Hashable}}
624624
_ = ty[] { 42 } // expected-error {{subscript index of type '() -> Int' in a key path must be Hashable}}
625625
_ = ty[] { 42 } = 0 // expected-error {{subscript index of type '() -> Int' in a key path must be Hashable}}

0 commit comments

Comments
 (0)