Swiftformat: Non-optional backticks removed from KeyPath

Created on 17 Jan 2019  路  6Comments  路  Source: nicklockwood/SwiftFormat

Formatting

struct Foo {
    let `defer`: Bool
}

let foo: KeyPath<Foo, Bool> = \.`defer`

results in

struct Foo {
    let `defer`: Bool
}

let foo: KeyPath<Foo, Bool> = \.defer // 馃洃 error: consecutive statements on a line must be separated by ';'

My guess - Keywords are not checked in KeyPaths in the redundantBackticks rule?

Apparently only checks on the shorthand notation are needed. The following compiles fine:

struct Foo {
    let `defer`: Bool
}

let foo: KeyPath<Foo, Bool> = \Foo.defer

This has really low priority to me, and I'd be fine inserting a comment for the linter there.

Thought it still might be worth the report

All 6 comments

@PabloSichert thanks for reporting this. Even obscure/low-pri bugs are worth reporting, as they might be indicative of a larger issue 馃憤

@PabloSichert fixed in 0.37.3

Just built swiftformat from source and can confirm it's fixed (doesn't seem to be released on brew yet).

Thank you!

Small update:

let foo: KeyPath<Foo, Bool> = \.defer

seems to be valid syntax as of Swift 5.0.

@pablosichert thanks for the update - I'll add a version-specific check.

This check has been added in 0.41.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

meherkasam picture meherkasam  路  3Comments

Cyberbeni picture Cyberbeni  路  4Comments

PompeiaPaetenari picture PompeiaPaetenari  路  3Comments

MaxDesiatov picture MaxDesiatov  路  3Comments

MaxDesiatov picture MaxDesiatov  路  4Comments