Skip to content

InlayHint textEdits are not always correct #759

Closed
@adam-fowler

Description

@adam-fowler

The text edits supplied with InlayHints don't always provide code that will compile eg adding the inlay hint to a closure argument would generate invalid code

func test(_ process: (String) -> ()) {
    process("hello")
}
test { string in 
    print(string)
}

The inlay hint for string is : String. The text edit that goes along with it is the same and inserting it would generate the following code

test { string: String in
    print(string)
}

which does not compile.

Another example is enums with associated values

case .test(let value):

becomes

case .test(let value: (String)):

Maybe we should disable the text edit option until we can be sure it returns valid code.

See swiftlang/vscode-swift#554 where this was originally reported

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions