Skip to content

Commit 9b6ba43

Browse files
authored
Merge pull request #24280 from kitasuke/SR-10469-func-call-args_list
SR-10469 Unknown syntax for interpolated string literal
2 parents 320d063 + 27cb9c4 commit 9b6ba43

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
18981898
/*isPostfix=*/false, /*isExprBasic=*/true,
18991899
lParen, args, argLabels, argLabelLocs, rParen,
19001900
trailingClosureNeverPresent,
1901-
SyntaxKind::Unknown);
1901+
SyntaxKind::FunctionCallArgumentList);
19021902
assert(!trailingClosureNeverPresent);
19031903

19041904
Status |= S;

test/IDE/complete_expr_postfix_begin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_1 | %FileCheck %s -check-prefix=COMMON
22
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_2 | %FileCheck %s -check-prefix=COMMON
33
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_3 | %FileCheck %s -check-prefix=COMMON
4-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_4 | %FileCheck %s -check-prefix=COMMON
4+
// RUN-FIXME: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_4 | %FileCheck %s -check-prefix=COMMON
55
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_5 | %FileCheck %s -check-prefix=COMMON
66
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=EXPR_POSTFIX_BEGIN_6 | %FileCheck %s -check-prefix=COMMON
77

test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class C <MemberDeclBlock>{<MemberDeclListItem><FunctionDecl>
2626
func bar3<FunctionSignature><ParameterClause>(<FunctionParameter>a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause></FunctionSignature><CodeBlock>{ <ReturnStmt>return <IntegerLiteralExpr>1 </IntegerLiteralExpr></ReturnStmt>}</CodeBlock></FunctionDecl></MemberDeclListItem><MemberDeclListItem><FunctionDecl>
2727
func bar4<FunctionSignature><ParameterClause>(<FunctionParameter>_ a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause></FunctionSignature><CodeBlock>{ <ReturnStmt>return <IntegerLiteralExpr>1 </IntegerLiteralExpr></ReturnStmt>}</CodeBlock></FunctionDecl></MemberDeclListItem><MemberDeclListItem><FunctionDecl>
2828
func foo<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<VariableDecl>
29-
var <PatternBinding><IdentifierPattern>a </IdentifierPattern><InitializerClause>= <StringInterpolationExpr>/*comment*/"<StringSegment>ab</StringSegment><ExpressionSegment>\(<IdentifierExpr>x</IdentifierExpr>)</ExpressionSegment><StringSegment>c</StringSegment>"</StringInterpolationExpr></InitializerClause></PatternBinding></VariableDecl><VariableDecl>/*comment*/
29+
var <PatternBinding><IdentifierPattern>a </IdentifierPattern><InitializerClause>= <StringInterpolationExpr>/*comment*/"<StringSegment>ab</StringSegment><ExpressionSegment>\(<FunctionCallArgument><IdentifierExpr>x</IdentifierExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment>c</StringSegment>"</StringInterpolationExpr></InitializerClause></PatternBinding></VariableDecl><VariableDecl>/*comment*/
3030
var <PatternBinding><IdentifierPattern>b </IdentifierPattern><InitializerClause>= <PrefixOperatorExpr>/*comment*/+<IntegerLiteralExpr>2</IntegerLiteralExpr></PrefixOperatorExpr></InitializerClause></PatternBinding></VariableDecl><FunctionCallExpr><IdentifierExpr>/*comment*/
3131
bar</IdentifierExpr>(<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
3232
bar</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>+<IntegerLiteralExpr>10</IntegerLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
@@ -434,11 +434,12 @@ extension <SimpleTypeIdentifier>ext </SimpleTypeIdentifier><GenericWhereClause>w
434434
extension <MemberTypeIdentifier><MemberTypeIdentifier><SimpleTypeIdentifier>ext</SimpleTypeIdentifier>.a</MemberTypeIdentifier>.b </MemberTypeIdentifier><MemberDeclBlock>{}</MemberDeclBlock></ExtensionDecl><FunctionDecl>
435435

436436
func foo<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<VariableDecl>
437-
var <PatternBinding><IdentifierPattern>a </IdentifierPattern><InitializerClause>= <StringInterpolationExpr>"<StringSegment>abc </StringSegment><ExpressionSegment>\(<FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr>)</ExpressionSegment><StringSegment> def </StringSegment><ExpressionSegment>\(<SequenceExpr><IdentifierExpr>a </IdentifierExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IdentifierExpr>b </IdentifierExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><StringInterpolationExpr>"<StringSegment>a </StringSegment><ExpressionSegment>\(<IntegerLiteralExpr>3</IntegerLiteralExpr>)</ExpressionSegment><StringSegment></StringSegment>"</StringInterpolationExpr></SequenceExpr>)</ExpressionSegment><StringSegment> gh</StringSegment>"</StringInterpolationExpr></InitializerClause></PatternBinding></VariableDecl><VariableDecl>
437+
var <PatternBinding><IdentifierPattern>a </IdentifierPattern><InitializerClause>= <StringInterpolationExpr>"<StringSegment>abc </StringSegment><ExpressionSegment>\(<FunctionCallArgument><FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment> def </StringSegment><ExpressionSegment>\(<FunctionCallArgument><SequenceExpr><IdentifierExpr>a </IdentifierExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IdentifierExpr>b </IdentifierExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><StringInterpolationExpr>"<StringSegment>a </StringSegment><ExpressionSegment>\(<FunctionCallArgument><IntegerLiteralExpr>3</IntegerLiteralExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment></StringSegment>"</StringInterpolationExpr></SequenceExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment> gh </StringSegment><ExpressionSegment>\(<FunctionCallArgument><IdentifierExpr>bar</IdentifierExpr>, </FunctionCallArgument><FunctionCallArgument>default: <IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment></StringSegment>"</StringInterpolationExpr></InitializerClause></PatternBinding></VariableDecl><VariableDecl>
438438
var <PatternBinding><IdentifierPattern>a </IdentifierPattern><InitializerClause>= <StringInterpolationExpr>"""<StringSegment>
439-
abc </StringSegment><ExpressionSegment>\( <SequenceExpr><FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>() </FunctionCallExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><FunctionCallExpr><IdentifierExpr>bar</IdentifierExpr>() </FunctionCallExpr></SequenceExpr>)</ExpressionSegment><StringSegment>
440-
de </StringSegment><ExpressionSegment>\(<SequenceExpr><IntegerLiteralExpr>3 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>3 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><StringInterpolationExpr>"<StringSegment>abc </StringSegment><ExpressionSegment>\(<FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr>)</ExpressionSegment><StringSegment> def</StringSegment>"</StringInterpolationExpr></SequenceExpr>)</ExpressionSegment><StringSegment>
439+
abc </StringSegment><ExpressionSegment>\( <FunctionCallArgument><SequenceExpr><FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>() </FunctionCallExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><FunctionCallExpr><IdentifierExpr>bar</IdentifierExpr>() </FunctionCallExpr></SequenceExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment>
440+
de </StringSegment><ExpressionSegment>\(<FunctionCallArgument><SequenceExpr><IntegerLiteralExpr>3 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>3 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><StringInterpolationExpr>"<StringSegment>abc </StringSegment><ExpressionSegment>\(<FunctionCallArgument><FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment> def</StringSegment>"</StringInterpolationExpr></SequenceExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment>
441441
fg
442+
</StringSegment><ExpressionSegment>\(<FunctionCallArgument><IdentifierExpr>bar</IdentifierExpr>, </FunctionCallArgument><FunctionCallArgument>default: <IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</ExpressionSegment><StringSegment>
442443
</StringSegment>"""</StringInterpolationExpr></InitializerClause></PatternBinding></VariableDecl>
443444
}</CodeBlock></FunctionDecl><FunctionDecl>
444445

test/Syntax/Parser/tree.swift.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
// RUN: diff -u %s.result %t.result
44

55
|func| </t6><t105>|test|</t105><NULL/><s110><s108><t88>|(|</t88><s174></s174><t89>|)| </t89></s108><NULL/><NULL/></s110><NULL/><s93><t90>|{|</t90><s163><s92><s64><t102>
6-
|"|</t102><s168><s104><t104>|a|</t104></s104><s105><t100>|\|</t100><t88>|(|</t88><s28><t105>|b|</t105><NULL/></s28><t101>|)|</t101></s105><s104><t104>|c|</t104></s104></s168><t102>|"|</t102></s64><NULL/><NULL/></s92></s163><t91>
6+
|"|</t102><s168><s104><t104>|a|</t104></s104><s105><t100>|\|</t100><t88>|(|</t88><s164><s96><NULL/><NULL/><s28><t105>|b|</t105><NULL/></s28><NULL/></s96></s164><t101>|)|</t101></s105><s104><t104>|c|</t104></s104></s168><t102>|"|</t102></s64><NULL/><NULL/></s92></s163><t91>
77
|}|</t91></s93></s13><NULL/><NULL/></s92></s163><t0>
88
||</t0></s118>

test/Syntax/round_trip_parse_gen.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,12 @@ extension ext where A == Int, B: Numeric {}
434434
extension ext.a.b {}
435435

436436
func foo() {
437-
var a = "abc \(foo()) def \(a + b + "a \(3)") gh"
437+
var a = "abc \(foo()) def \(a + b + "a \(3)") gh \(bar, default: 1)"
438438
var a = """
439439
abc \( foo() + bar() )
440440
de \(3 + 3 + "abc \(foo()) def")
441441
fg
442+
\(bar, default: 1)
442443
"""
443444
}
444445

utils/gyb_syntax_support/ExprNodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@
470470
Child('LeftParen', kind='LeftParenToken',
471471
classification='StringInterpolationAnchor',
472472
force_classification=True),
473-
Child('Expression', kind='Expr'),
473+
Child('Expressions', kind='FunctionCallArgumentList',
474+
collection_element_name='Expression'),
474475
Child('RightParen', kind='StringInterpolationAnchorToken'),
475476
]),
476477

0 commit comments

Comments
 (0)