Skip to content

Commit f2ef161

Browse files
authored
Merge pull request #2422 from ahoppen/ahoppen/fixme-cleanup
Removes TODOs and FIXMEs that are no longer applicable
2 parents 23e4c01 + 4354b33 commit f2ef161

24 files changed

+29
-82
lines changed

Sources/SwiftParser/Availability.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ extension Parser {
145145
case (.unavailable, let handle)?,
146146
(.noasync, let handle)?:
147147
let argument = self.eat(handle)
148-
// FIXME: Can we model this in SwiftSyntax by making the
149-
// 'labeled' argument part optional?
150148
entry = .token(argument)
151149
case (.star, _)?:
152150
entry = self.parseAvailabilitySpec()
@@ -177,8 +175,6 @@ extension Parser {
177175
/// Parse an availability argument.
178176
mutating func parseAvailabilitySpec() -> RawAvailabilityArgumentSyntax.Argument {
179177
if let star = self.consumeIfContextualPunctuator("*") {
180-
// FIXME: Use makeAvailabilityVersionRestriction here - but swift-format
181-
// doesn't expect it.
182178
return .token(star)
183179
}
184180

Sources/SwiftParser/Declarations.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ extension TokenConsumer {
135135
}
136136

137137
// Otherwise, parse it as an expression.
138-
// FIXME: C++ parser returns true if this is a top-level non-"script" files.
139-
// But we don't have "is library" flag.
140138
return false
141139
case .some(_):
142140
// All other decl start keywords unconditionally start a decl.
@@ -1670,8 +1668,10 @@ extension Parser {
16701668
let (unexpectedBeforeIdentifier, identifier) = self.expectIdentifier(allowSelfOrCapitalSelfAsIdentifier: true)
16711669
var types = [RawDesignatedTypeSyntax]()
16721670
while let comma = self.consume(if: .comma) {
1673-
// FIXME: The compiler accepts... anything here. This is a bug.
1674-
// let (unexpectedBeforeDesignatedType, designatedType) = self.expectIdentifier()
1671+
// Technically, we should only accept identifiers for the designated
1672+
// types but the C++ parser accepted anything, which we mimick.
1673+
// It's not worth fixing since designated types are no longer allowed
1674+
// anyway.
16751675
let designatedType = self.consumeAnyToken()
16761676
types.append(
16771677
RawDesignatedTypeSyntax(

Sources/SwiftParser/Expressions.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ extension Parser {
791791

792792
// Check for a trailing closure, if allowed.
793793
if self.at(.leftBrace) && !leadingExpr.raw.kind.isLiteral && self.withLookahead({ $0.atValidTrailingClosure(flavor: flavor) }) {
794-
// FIXME: if Result has a trailing closure, break out.
795794
// Add dummy blank argument list to the call expression syntax.
796795
let list = RawLabeledExprListSyntax(elements: [], arena: self.arena)
797796
let (first, rest) = self.parseTrailingClosures(flavor: flavor)
@@ -1472,7 +1471,6 @@ extension Parser {
14721471
}
14731472

14741473
if let (colon, rsquare) = self.consume(if: .colon, followedBy: .rightSquare) {
1475-
// FIXME: We probably want a separate node for the empty case.
14761474
return RawExprSyntax(
14771475
RawDictionaryExprSyntax(
14781476
unexpectedBeforeLSquare,

Sources/SwiftParser/TopLevel.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ extension Parser {
150150
)
151151
}
152152

153-
// FIXME: It is unfortunate that the Swift book refers to these as
154-
// "statements" and not "items".
155153
let item = self.parseItem(isAtTopLevel: isAtTopLevel, allowInitDecl: allowInitDecl)
156154
let semi = self.consume(if: .semicolon)
157155
var trailingSemis: [RawTokenSyntax] = []

Sources/SwiftParser/Types.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ extension Parser {
380380
/// Parse a type placeholder.
381381
mutating func parsePlaceholderType() -> RawIdentifierTypeSyntax {
382382
let (unexpectedBeforeName, name) = self.expect(.wildcard)
383-
// FIXME: Need a better syntax node than this
384383
return RawIdentifierTypeSyntax(
385384
unexpectedBeforeName,
386385
name: name,

Sources/SwiftParserDiagnostics/MissingTokenError.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ extension ParseDiagnosticsGenerator {
4949
private func handleInvalidIdentifier(invalidToken: TokenSyntax, missingToken: TokenSyntax, invalidTokenContainer: UnexpectedNodesSyntax) -> Bool {
5050
let fixIts: [FixIt]
5151
if invalidToken.tokenKind.isLexerClassifiedKeyword || invalidToken.tokenKind.isDollarIdentifier {
52-
// TODO: Should the parser add the text with backticks to the missing
53-
// node? Then this could just make missing/present.
5452
fixIts = [
5553
FixIt(
5654
message: .wrapInBackticks,

Sources/SwiftParserDiagnostics/MultiLineStringLiteralDiagnosticsGenerator.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ final class MultiLineStringLiteralIndentationDiagnosticsGenerator: SyntaxVisitor
133133
case .stringSegment(let stringSegment):
134134
return stringSegment.last?.isNewline ?? false
135135
default:
136-
// FIXME: newlines should never be part of trailing trivia
137136
return previousToken.trailingTrivia.contains(where: { $0.isNewline })
138137
}
139138
}

Sources/SwiftSyntax/Raw/RawSyntaxNodeProtocol.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ public struct RawTokenSyntax: RawSyntaxNodeProtocol {
270270
trailingTriviaPieces: [RawTriviaPiece] = [],
271271
arena: __shared SyntaxArena
272272
) {
273-
// FIXME: Allow creating a `RawSyntax.parsedToken()` with a string literal
274-
// for text. Currently it asserts that the string buffer is not contained
275-
// within the `arena`.
276273
self.init(
277274
materialized: kind,
278275
text: text ?? kind.defaultText ?? "",

Sources/SwiftSyntax/SyntaxChildren.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ struct RawSyntaxChildren: BidirectionalCollection {
153153

154154
/// The rootId of the tree the child nodes belong to
155155
private let rootId: UInt
156+
156157
/// The number of children in `parent`. Cached to avoid reaching into `parent` for every index
157158
/// advancement
158-
// FIXME: Do we need this cached?
159159
private let numberOfChildren: Int
160160

161161
let startIndex: SyntaxChildrenIndex

Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ extension String: ExpressibleByLiteralSyntax {
268268

269269
extension ExpressibleByLiteralSyntax where Self: BinaryInteger {
270270
public func makeLiteralSyntax() -> IntegerLiteralExprSyntax {
271-
// TODO: Radix selection? Thousands separators?
272271
let digits = String(self, radix: 10)
273272
return IntegerLiteralExprSyntax(literal: .integerLiteral(digits))
274273
}
@@ -305,7 +304,6 @@ extension ExpressibleByLiteralSyntax where Self: FloatingPoint, Self: LosslessSt
305304
)
306305

307306
case .negativeNormal, .negativeSubnormal, .positiveZero, .positiveSubnormal, .positiveNormal:
308-
// TODO: Thousands separators?
309307
let digits = String(self)
310308
return ExprSyntax(FloatLiteralExprSyntax(literal: .floatLiteral(digits)))
311309
}

Sources/SwiftSyntaxBuilder/SyntaxParsable+ExpressibleByStringInterpolation.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ extension SyntaxParseable {
7171
public init(stringInterpolation: SyntaxStringInterpolation) {
7272
self = stringInterpolation.sourceText.withUnsafeBufferPointer { buffer in
7373
var parser = Parser(buffer)
74-
// FIXME: When the parser supports incremental parsing, put the
75-
// interpolatedSyntaxNodes in so we don't have to parse them again.
7674
let result = Self.parse(from: &parser)
7775
return result
7876
}

Tests/SwiftParserTest/translated/DollarIdentifierTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ final class DollarIdentifierTests: ParserTestCase {
188188
assertParse(
189189
"""
190190
func escapedDollarAnd() {
191-
// FIXME: Bad diagnostics.
192191
1️⃣`$0` = 1
193192
`$$` = 2
194193
`$abc` = 3
195194
}
196195
""",
197196
diagnostics: [
197+
// FIXME: Bad diagnostic
198198
DiagnosticSpec(message: "unexpected code in function")
199199
]
200200
)

Tests/SwiftParserTest/translated/EnumElementPatternSwift4Tests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515
import XCTest
1616

1717
final class EnumElementPatternSwift4Tests: ParserTestCase {
18-
func testEnumElementPatternSwift41() {
19-
assertParse(
20-
"""
21-
// https://github.com/apple/swift/issues/46040
22-
// See test/Compatibility/enum_element_pattern.swift for Swift3 behavior.
23-
// As for FIXME cases: see https://github.com/apple/swift/issues/46054
24-
"""
25-
)
26-
}
27-
2818
func testEnumElementPatternSwift42() {
2919
assertParse(
3020
"""

Tests/SwiftParserTest/translated/EnumTests.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@
1515
import XCTest
1616

1717
final class EnumTests: ParserTestCase {
18-
func testEnum1() {
19-
assertParse(
20-
"""
21-
// FIXME: this test only passes on platforms which have Float80.
22-
// <rdar://problem/19508460> Floating point enum raw values are not portable
23-
"""
24-
)
25-
}
26-
2718
func testEnum2() {
2819
assertParse(
2920
"""
@@ -705,7 +696,6 @@ final class EnumTests: ParserTestCase {
705696
assertParse(
706697
"""
707698
enum RawTypeWithRepeatValues5 : Double {
708-
// FIXME: should reject.
709699
// 2^65-1
710700
case Vaughn = 36893488147419103231
711701
case Wilson = 36893488147419103231.0
@@ -718,7 +708,6 @@ final class EnumTests: ParserTestCase {
718708
assertParse(
719709
"""
720710
enum RawTypeWithRepeatValues6 : Double {
721-
// FIXME: should reject.
722711
// 2^127-1
723712
case Vaughn = 170141183460469231731687303715884105727
724713
case Wilson = 170141183460469231731687303715884105727.0
@@ -731,7 +720,6 @@ final class EnumTests: ParserTestCase {
731720
assertParse(
732721
"""
733722
enum RawTypeWithRepeatValues7 : Double {
734-
// FIXME: should reject.
735723
// 2^128-1
736724
case Vaughn = 340282366920938463463374607431768211455
737725
case Wilson = 340282366920938463463374607431768211455.0

Tests/SwiftParserTest/translated/GenericDisambiguationTests.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ final class GenericDisambiguationTests: ParserTestCase {
213213
}
214214

215215
func testGenericDisambiguation15() {
216-
// TODO: parse empty <> list
217216
assertParse(
218217
"""
219218
A<>.c()
220-
"""
219+
""",
220+
substructure: PostfixOperatorExprSyntax(
221+
expression: ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("A"))),
222+
operator: .postfixOperator("<>")
223+
)
221224
)
222225
}
223226

Tests/SwiftParserTest/translated/IfconfigExprTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ final class IfconfigExprTests: ParserTestCase {
500500
)
501501
}
502502

503-
// FIXME: Diagnostics could be better.
504503
func testIfConfigExpr34() {
505504
assertParse(
506505
"""

Tests/SwiftParserTest/translated/MatchingPatternsTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,6 @@ final class MatchingPatternsTests: ParserTestCase {
509509
func testMatchingPatterns31() {
510510
assertParse(
511511
#"""
512-
// FIXME: We don't currently allow subpatterns for "isa" patterns that
513-
// require interesting conditional downcasts.
514512
class Base { }
515513
class Derived : Base { }
516514
"""#

Tests/SwiftParserTest/translated/OperatorDeclTests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ final class OperatorDeclTests: ParserTestCase {
351351
}
352352

353353
func testOperatorDecl13() {
354-
// FIXME: Ideally, we shouldn't emit the «consistent whitespace» diagnostic
355-
// where = cannot possibly mean an assignment.
356354
assertParse(
357355
"""
358356
infix operator =1️⃣#=
@@ -528,7 +526,6 @@ final class OperatorDeclTests: ParserTestCase {
528526
}
529527

530528
func testOperatorDecl21() {
531-
// TODO: We should not allow specification of multiple precedence groups
532529
assertParse(
533530
"""
534531
protocol Proto {}

Tests/SwiftParserTest/translated/RecoveryTests.swift

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// This test file has been translated from swift/test/Parse/recovery.swift
1414

15+
import SwiftSyntax
1516
import XCTest
1617

1718
final class RecoveryTests: ParserTestCase {
@@ -290,10 +291,6 @@ final class RecoveryTests: ParserTestCase {
290291
""",
291292
diagnostics: [
292293
DiagnosticSpec(message: "missing condition in 'if' statement")
293-
// TODO: Old parser expected error on line 3: consecutive statements on a line must be separated by ';', Fix-It replacements: 14 - 14 = ';'
294-
// TODO: Old parser expected error on line 3: closure expression is unused
295-
// TODO: Old parser expected note on line 3: did you mean to use a 'do' statement?, Fix-It replacements: 15 - 15 = 'do '
296-
// TODO: Old parser expected warning on line 3: boolean literal is unused
297294
]
298295
)
299296
}
@@ -318,8 +315,6 @@ final class RecoveryTests: ParserTestCase {
318315
""",
319316
diagnostics: [
320317
DiagnosticSpec(message: "missing condition in 'if' statement")
321-
// TODO: Old parser expected error on line 2: closure expression is unused
322-
// TODO: Old parser expected note on line 2: did you mean to use a 'do' statement?, Fix-It replacements: 8 - 8 = 'do '
323318
]
324319
)
325320
}
@@ -374,10 +369,6 @@ final class RecoveryTests: ParserTestCase {
374369
""",
375370
diagnostics: [
376371
DiagnosticSpec(message: "missing condition in 'while' statement")
377-
// TODO: Old parser expected error on line 3: consecutive statements on a line must be separated by ';', Fix-It replacements: 17 - 17 = ';'
378-
// TODO: Old parser expected error on line 3: closure expression is unused
379-
// TODO: Old parser expected note on line 3: did you mean to use a 'do' statement?, Fix-It replacements: 18 - 18 = 'do '
380-
// TODO: Old parser expected warning on line 3: boolean literal is unused
381372
]
382373
)
383374
}
@@ -402,8 +393,6 @@ final class RecoveryTests: ParserTestCase {
402393
""",
403394
diagnostics: [
404395
DiagnosticSpec(message: "missing condition in 'while' statement")
405-
// TODO: Old parser expected error on line 2: closure expression is unused
406-
// TODO: Old parser expected note on line 2: did you mean to use a 'do' statement?, Fix-It replacements: 11 - 11 = 'do '
407396
]
408397
)
409398
}
@@ -814,7 +803,6 @@ final class RecoveryTests: ParserTestCase {
814803
""",
815804
diagnostics: [
816805
DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement")
817-
// TODO: Old parser expected error on line 2: 'is' keyword required to pattern match against type name, Fix-It replacements: 10 - 10 = 'is '
818806
]
819807
)
820808
}
@@ -2871,9 +2859,23 @@ final class RecoveryTests: ParserTestCase {
28712859
&(Int:x)
28722860
}
28732861
""",
2874-
diagnostics: [
2875-
// TODO: Old parser expected error on line 4: '&' may only be used to pass an argument to inout parameter
2876-
]
2862+
substructure: InOutExprSyntax(
2863+
ampersand: .prefixAmpersandToken(),
2864+
expression: ExprSyntax(
2865+
TupleExprSyntax(
2866+
leftParen: .leftParenToken(),
2867+
elements: LabeledExprListSyntax([
2868+
LabeledExprSyntax(
2869+
label: .identifier("Int"),
2870+
colon: .colonToken(),
2871+
expression: ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("x")))
2872+
)
2873+
]),
2874+
rightParen: .rightParenToken()
2875+
)
2876+
)
2877+
)
2878+
28772879
)
28782880
}
28792881

Tests/SwiftParserTest/translated/StringLiteralEofTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ final class StringLiteralEofTests: ParserTestCase {
164164
\(<#expression#>)
165165
"""
166166
"""##
167-
// FIXME: The closing delimiter should be put on the new line
168167
)
169168
}
170169

Tests/SwiftParserTest/translated/SubscriptingTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ final class SubscriptingTests: ParserTestCase {
176176
func testSubscripting11() {
177177
assertParse(
178178
"""
179-
// FIXME: This test case does not belong in Parse/
180179
let y2 = Y2()
181180
_ = y2[0]
182181
"""

Tests/SwiftParserTest/translated/SuperTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ final class SuperTests: ParserTestCase {
9292
super.foo.bar
9393
super.bar
9494
super.bar()
95-
// FIXME: should also say "'super.init' cannot be referenced outside of an initializer"
9695
super.init
9796
super.init()
9897
super.init(0)

Tests/SwiftParserTest/translated/TypeExprTests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ final class TypeExprTests: ParserTestCase {
4343
protocol Zim {
4444
associatedtype Zang
4545
init()
46-
// TODO class var prop: Int { get }
4746
static func meth() {}
4847
func instMeth() {}
4948
}
@@ -224,7 +223,6 @@ final class TypeExprTests: ParserTestCase {
224223
func archetype<T: Zim>(_: T) {
225224
_ = T.self
226225
_ = T()
227-
// TODO let prop = T.prop
228226
_ = T.meth
229227
let _ : () = T.meth()
230228
_ = T
@@ -239,7 +237,6 @@ final class TypeExprTests: ParserTestCase {
239237
func assocType<T: Zim>(_: T) where T.Zang: Zim {
240238
_ = T.Zang.self
241239
_ = T.Zang()
242-
// TODO _ = T.Zang.prop
243240
_ = T.Zang.meth
244241
let _ : () = T.Zang.meth()
245242
_ = T.Zang

0 commit comments

Comments
 (0)