Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3c4db58

Browse filesBrowse files
authored
Merge pull request #3089 from hamishknight/x-of-hearts-6.2
[6.2] Change InlineArray sugar separator `x` -> `of`
2 parents 0dff260 + 872fe13 commit 3c4db58
Copy full SHA for 3c4db58

File tree

Expand file treeCollapse file tree

10 files changed

+55
-68
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+55
-68
lines changed

‎CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

Copy file name to clipboardExpand all lines: CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ public enum Keyword: CaseIterable {
275275
case `while`
276276
case willSet
277277
case wrt
278-
case x
279278
case yield
280279

281280
public var spec: KeywordSpec {
@@ -682,8 +681,6 @@ public enum Keyword: CaseIterable {
682681
return KeywordSpec("willSet")
683682
case .wrt:
684683
return KeywordSpec("wrt")
685-
case .x:
686-
return KeywordSpec("x", experimentalFeature: .inlineArrayTypeSugar)
687684
case .yield:
688685
return KeywordSpec("yield")
689686
}

‎CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Copy file name to clipboardExpand all lines: CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public let TYPE_NODES: [Node] = [
304304
base: .type,
305305
experimentalFeature: .inlineArrayTypeSugar,
306306
nameForDiagnostics: "inline array type",
307-
documentation: "An inline array type `[3 x Int]`, sugar for `InlineArray<3, Int>`.",
307+
documentation: "An inline array type `[3 of Int]`, sugar for `InlineArray<3, Int>`.",
308308
children: [
309309
Child(
310310
name: "leftSquare",
@@ -317,12 +317,12 @@ public let TYPE_NODES: [Node] = [
317317
documentation: """
318318
The `count` argument for the inline array type.
319319
320-
- Note: In semantically valid Swift code, this is always an integer or a wildcard type, e.g `_` in `[_ x Int]`.
320+
- Note: In semantically valid Swift code, this is always an integer or a wildcard type, e.g `_` in `[_ of Int]`.
321321
"""
322322
),
323323
Child(
324324
name: "separator",
325-
kind: .token(choices: [.keyword(.x)])
325+
kind: .token(choices: [.keyword(.of)])
326326
),
327327
Child(
328328
name: "element",

‎CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Copy file name to clipboardExpand all lines: CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,11 @@ class ValidateSyntaxNodes: XCTestCase {
372372
message:
373373
"child 'defaultKeyword' has a single keyword as its only token choice and is followed by a colon. It should thus be named 'defaultLabel'"
374374
),
375-
// 'separator' is more descriptive than 'xKeyword'
375+
// 'separator' is more descriptive than 'ofKeyword'
376376
ValidationFailure(
377377
node: .inlineArrayType,
378-
message: "child 'separator' has a single keyword as its only token choice and should thus be named 'xKeyword'"
378+
message:
379+
"child 'separator' has a single keyword as its only token choice and should thus be named 'ofKeyword'"
379380
),
380381
]
381382
)

‎Sources/SwiftParser/TokenPrecedence.swift

Copy file name to clipboardExpand all lines: Sources/SwiftParser/TokenPrecedence.swift
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ enum TokenPrecedence: Comparable {
344344
.visibility,
345345
.weak,
346346
.wrt,
347-
.x,
348347
.unsafe:
349348
self = .exprKeyword
350349
#if RESILIENT_LIBRARIES

‎Sources/SwiftParser/Types.swift

Copy file name to clipboardExpand all lines: Sources/SwiftParser/Types.swift
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,11 @@ extension Parser {
649649
precondition(self.experimentalFeatures.contains(.inlineArrayTypeSugar))
650650

651651
// We allow both values and types here and for the element type for
652-
// better recovery in cases where the user writes e.g '[Int x 3]'.
652+
// better recovery in cases where the user writes e.g '[Int of 3]'.
653653
let count = self.parseGenericArgumentType()
654654

655655
let (unexpectedBeforeSeparator, separator) = self.expect(
656-
TokenSpec(.x, allowAtStartOfLine: false)
656+
TokenSpec(.of, allowAtStartOfLine: false)
657657
)
658658

659659
let element = self.parseGenericArgumentType()
@@ -879,26 +879,26 @@ extension Parser.Lookahead {
879879
return false
880880
}
881881

882-
// We must have at least '[<type-or-integer> x', which cannot be any other
882+
// We must have at least '[<type-or-integer> of', which cannot be any other
883883
// kind of expression or type. We specifically look for both types and
884884
// integers for better recovery in e.g cases where the user writes e.g
885-
// '[Int x 2]'. We only do type-scalar since variadics would be ambiguous
886-
// e.g 'Int...x'.
885+
// '[Int of 2]'. We only do type-scalar since variadics would be ambiguous
886+
// e.g 'Int...of'.
887887
guard self.canParseTypeScalar() || self.canParseIntegerLiteral() else {
888888
return false
889889
}
890890

891891
// We don't currently allow multi-line since that would require
892892
// disambiguation with array literals.
893-
return self.consume(if: TokenSpec(.x, allowAtStartOfLine: false)) != nil
893+
return self.consume(if: TokenSpec(.of, allowAtStartOfLine: false)) != nil
894894
}
895895

896896
mutating func canParseInlineArrayTypeBody() -> Bool {
897897
guard self.canParseStartOfInlineArrayTypeBody() else {
898898
return false
899899
}
900900
// Note we look for both types and integers for better recovery in e.g cases
901-
// where the user writes e.g '[Int x 2]'.
901+
// where the user writes e.g '[Int of 2]'.
902902
guard self.canParseGenericArgument() else {
903903
return false
904904
}

‎Sources/SwiftSyntax/generated/Keyword.swift

Copy file name to clipboardExpand all lines: Sources/SwiftSyntax/generated/Keyword.swift
-10Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift

Copy file name to clipboardExpand all lines: Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift

Copy file name to clipboardExpand all lines: Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift
+5-5Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Tests/SwiftParserTest/ExpressionTypeTests.swift

Copy file name to clipboardExpand all lines: Tests/SwiftParserTest/ExpressionTypeTests.swift
+20-20Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,26 @@ final class ExpressionTypeTests: ParserTestCase {
111111
// Make sure we can handle cases where the type is spelled first in
112112
// an InlineArray sugar type.
113113
let cases: [UInt: String] = [
114-
#line: "[3 x Int]",
115-
#line: "[[3 x Int]]",
116-
#line: "[[Int x 3]]",
117-
#line: "[_ x Int]",
118-
#line: "[Int x Int]",
119-
#line: "[@escaping () -> Int x Int]",
120-
#line: "[Int.Type x Int]",
121-
#line: "[sending P & Q x Int]",
122-
#line: "[(some P & Q) -> Int x Int]",
123-
#line: "[~P x Int]",
124-
#line: "[(Int, String) x Int]",
125-
#line: "[G<T> x Int]",
126-
#line: "[[3 x Int] x Int]",
127-
#line: "[[Int] x Int]",
128-
#line: "[_ x Int]",
129-
#line: "[_? x Int]",
130-
#line: "[_?x Int]",
131-
#line: "[_! x Int]",
132-
#line: "[_!x Int]",
133-
#line: "[Int?x Int]",
114+
#line: "[3 of Int]",
115+
#line: "[[3 of Int]]",
116+
#line: "[[Int of 3]]",
117+
#line: "[_ of Int]",
118+
#line: "[Int of Int]",
119+
#line: "[@escaping () -> Int of Int]",
120+
#line: "[Int.Type of Int]",
121+
#line: "[sending P & Q of Int]",
122+
#line: "[(some P & Q) -> Int of Int]",
123+
#line: "[~P of Int]",
124+
#line: "[(Int, String) of Int]",
125+
#line: "[G<T> of Int]",
126+
#line: "[[3 of Int] of Int]",
127+
#line: "[[Int] of Int]",
128+
#line: "[_ of Int]",
129+
#line: "[_? of Int]",
130+
#line: "[_?of Int]",
131+
#line: "[_! of Int]",
132+
#line: "[_!of Int]",
133+
#line: "[Int?of Int]",
134134
]
135135
for (line, type) in cases {
136136
assertParse(

‎Tests/SwiftParserTest/TypeTests.swift

Copy file name to clipboardExpand all lines: Tests/SwiftParserTest/TypeTests.swift
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -781,18 +781,18 @@ final class InlineArrayTypeTests: ParserTestCase {
781781

782782
func testBasic() {
783783
assertParse(
784-
"[3 x Int]",
784+
"[3 of Int]",
785785
substructure: InlineArrayTypeSyntax(
786786
count: .init(argument: .expr("3")),
787-
separator: .keyword(.x),
787+
separator: .keyword(.of),
788788
element: .init(argument: .type(TypeSyntax("Int")))
789789
)
790790
)
791791
assertParse(
792-
"[Int x _]",
792+
"[Int of _]",
793793
substructure: InlineArrayTypeSyntax(
794794
count: .init(argument: .type(TypeSyntax("Int"))),
795-
separator: .keyword(.x),
795+
separator: .keyword(.of),
796796
element: .init(argument: .type(TypeSyntax("_")))
797797
)
798798
)
@@ -804,7 +804,7 @@ final class InlineArrayTypeTests: ParserTestCase {
804804
"""
805805
S<[
806806
3
807-
1️⃣x
807+
1️⃣of
808808
Int
809809
]>()
810810
""",
@@ -815,7 +815,7 @@ final class InlineArrayTypeTests: ParserTestCase {
815815
assertParse(
816816
"""
817817
S<[3
818-
1️⃣x
818+
1️⃣of
819819
Int
820820
]>()
821821
""",
@@ -826,54 +826,54 @@ final class InlineArrayTypeTests: ParserTestCase {
826826
assertParse(
827827
"""
828828
S<[3
829-
1️⃣x Int]>()
829+
1️⃣of Int]>()
830830
""",
831831
diagnostics: [
832-
DiagnosticSpec(message: "unexpected code 'x Int' in array")
832+
DiagnosticSpec(message: "unexpected code 'of Int' in array")
833833
]
834834
)
835835
// These are okay.
836836
assertParse(
837837
"""
838-
S<[3 x
838+
S<[3 of
839839
Int]>()
840840
"""
841841
)
842842
assertParse(
843843
"""
844844
S<[
845-
3 x Int
845+
3 of Int
846846
]>()
847847
"""
848848
)
849849
}
850850

851851
func testDiagnostics() {
852852
assertParse(
853-
"2️⃣[3 x1️⃣",
853+
"2️⃣[3 of1️⃣",
854854
diagnostics: [
855855
DiagnosticSpec(
856856
message: "expected element type and ']' to end inline array type",
857857
fixIts: ["insert element type and ']'"]
858858
)
859859
],
860-
fixedSource: "[3 x <#type#>]"
860+
fixedSource: "[3 of <#type#>]"
861861
)
862862
assertParse(
863-
"ℹ️[3 x Int1️⃣",
863+
"ℹ️[3 of Int1️⃣",
864864
diagnostics: [
865865
DiagnosticSpec(
866866
message: "expected ']' to end inline array type",
867867
notes: [NoteSpec(message: "to match this opening '['")],
868868
fixIts: ["insert ']'"]
869869
)
870870
],
871-
fixedSource: "[3 x Int]"
871+
fixedSource: "[3 of Int]"
872872
)
873873
}
874874

875875
func testEllipsis() {
876-
// Make sure this isn't parsed as '<variadic-type> x <missing type>'
877-
assertParse("[x...x]")
876+
// Make sure this isn't parsed as '<variadic-type> of <missing type>'
877+
assertParse("[x...of]")
878878
}
879879
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.