Skip to content

InlayHint textEdits are not always correct #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adam-fowler opened this issue Jun 30, 2023 · 1 comment · Fixed by #770
Closed

InlayHint textEdits are not always correct #759

adam-fowler opened this issue Jun 30, 2023 · 1 comment · Fixed by #770

Comments

@adam-fowler
Copy link
Contributor

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

@ahoppen
Copy link
Member

ahoppen commented Jun 30, 2023

Tracked in Apple’s issue tracker as rdar://111559715

ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this issue Jul 17, 2023
…alid

Don’t offer any text edits for inlay hints displayed in closure paramters or enum case items.

Fixes swiftlang#759
rdar://111559715
ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this issue Jul 18, 2023
…alid

Don’t offer any text edits for inlay hints displayed in closure paramters or enum case items.

Fixes swiftlang#759
rdar://111559715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants