alex-pinkus / tree-sitter-swift

A tree-sitter grammar for the Swift programming language.
MIT License
134 stars 33 forks source link

Unterminated strings don't provide error recovery #397

Open wojciech-kulik opened 4 months ago

wojciech-kulik commented 4 months ago

I'm not sure if it's possible in case of Swift, but tree-sitter is often advertised by its error recovery and as one of examples it is shown that unterminated String doesn't break highlighting. That's not the case with Swift, if I leave open String the rest of the file is considered as String.

Would it be possible to handle this case. It should be possible because multiline Strings have its own syntax: """

Xcode handles this case correctly.

Example:

func foo() {
  let myLet = "abcd
  someObj.call()
}
alex-pinkus commented 4 months ago

Hmm, this is odd. My first assumption was that this came from the custom scanner, but then I remembered that single-line non-raw strings are part of the JS grammar, not the custom scanner.

wojciech-kulik commented 4 months ago

I'm not sure if I understood your comment :D. Is there any chance to fix it?

alex-pinkus commented 3 months ago

I'm sure it is possible to fix. My earlier comment is saying that I don't have any pointers on where you might look to start to fix it, though.