- 
                Notifications
    You must be signed in to change notification settings 
- Fork 253
Closed
Description
Summary
Swift can use experimental type sugar for InlineArray (e.g. [3 x Int]), and swift-syntax already has supported it, but swift-format hasn't supported it yet.
- pitch
- swiftlang/swift: Introduce type sugar for InlineArray swift#80087
- swiftlang/swift-syntax: Parse InlineArray type sugar swift-syntax#3021
Input
test.swift:
let a: [3 x Int] = [1, 2, 3]Expected result
let a: [3 x Int] = [1, 2, 3]Actual result
(with --enable-experimental-feature InlineArrayTypeSugar)
let a: [3xInt] = [1, 2, 3]However, this result causes compiler errrors.
$ swift-format format --enable-experimental-feature InlineArrayTypeSugar -i test.swift
$ swiftc -enable-experimental-feature InlineArrayTypeSugar test.swift
test.swift:1:10: error: 'x' is not a valid digit in integer literal
1 | let a: [3xInt] = [1, 2, 3]
  |          `- error: 'x' is not a valid digit in integer literal
2 | 
test.swift:1:9: error: expected element type
1 | let a: [3xInt] = [1, 2, 3]
  |         `- error: expected element type
2 | 
test.swift:1:9: error: expected ']' in array type
1 | let a: [3xInt] = [1, 2, 3]
  |        |`- error: expected ']' in array type
  |        `- note: to match this opening '['
2 | 
test.swift:1:14: error: consecutive statements on a line must be separated by ';'
1 | let a: [3xInt] = [1, 2, 3]
  |              `- error: consecutive statements on a line must be separated by ';'
2 | 
test.swift:1:14: error: expected expression
1 | let a: [3xInt] = [1, 2, 3]
  |              `- error: expected expression
2 | Environment
- swift-format: 58807b9
- swift-syntax: 820501e3cf5894ad1deb8de95649b938a8bbe9f4
TTOzzi
Metadata
Metadata
Assignees
Labels
No labels