Skip to content

Commit 124b0e4

Browse files
committed
Fix <rdar://problem/23719432> [practicalswift] Compiler crashes on &(Int:_)
We were using the wrong conversion from lvalue to rvalue, which wasn't digging into tuple lvalues.
1 parent 7d3292b commit 124b0e4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,11 +2651,10 @@ namespace {
26512651
// case (when we turn the inout into an UnsafePointer) than to try to
26522652
// discover that we're in that case right now.
26532653
expr->getSubExpr()->propagateLValueAccessKind(AccessKind::ReadWrite);
2654-
auto lvTy = expr->getSubExpr()->getType()->castTo<LValueType>();
2654+
auto objectTy = expr->getSubExpr()->getType()->getRValueType();
26552655

2656-
// The type is simply inout.
2657-
// Compute the type of the inout expression.
2658-
expr->setType(InOutType::get(lvTy->getObjectType()));
2656+
// The type is simply inout of whatever the lvalue's object type was.
2657+
expr->setType(InOutType::get(objectTy));
26592658
return expr;
26602659
}
26612660

test/Parse/recovery.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,3 +699,10 @@ func test23086402(a: A23086402) {
699699
print(a.b.c + "") // expected-error {{cannot convert value of type '[String]' to expected argument type 'String'}}
700700
}
701701

702+
// <rdar://problem/23719432> [practicalswift] Compiler crashes on &(Int:_)
703+
func test23719432() {
704+
var x = 42
705+
&(Int:x) // expected-error {{'&' can only appear immediately in a call argument list}}
706+
}
707+
708+

0 commit comments

Comments
 (0)