Skip to content

Commit 82be1a5

Browse files
committed
[parser] Make sure the isInputIncomplete() function works as expected when there is an empty string interpolation segment
Previously it was erroneously treating such invalid interpolation segment as 'incomplete', even though additional user input, will not 'complete' it. rdar://28498239
1 parent 1d47dc9 commit 82be1a5

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

include/swift/Parse/Parser.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ class Parser {
192192
bool isInputIncomplete() const { return IsInputIncomplete; }
193193

194194
void checkForInputIncomplete() {
195-
IsInputIncomplete = IsInputIncomplete || Tok.is(tok::eof);
195+
IsInputIncomplete = IsInputIncomplete ||
196+
// Check whether parser reached EOF but the real EOF, not the end of a
197+
// string interpolation segment.
198+
(Tok.is(tok::eof) && Tok.getText() != ")");
196199
}
197200

198201
/// \brief This is the current token being considered by the parser.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo("\()")

test/IDE/test-input-complete/test_input.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/type_incomplete2.swift | %FileCheck %s -check-prefix=INCOMPLETE
3131
// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/type_incomplete3.swift | %FileCheck %s -check-prefix=INCOMPLETE
3232
// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/type_incomplete4.swift | %FileCheck %s -check-prefix=INCOMPLETE
33+
// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/invalid_interpolation1.swift | %FileCheck %s -check-prefix=COMPLETE
3334

3435
// INCOMPLETE: IS_INCOMPLETE
3536
// COMPLETE: IS_COMPLETE

0 commit comments

Comments
 (0)