Skip to content
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

Incorrect syntax highlighting with single quotes #260

Closed
whoami730 opened this issue Aug 17, 2023 · 7 comments · Fixed by #261
Closed

Incorrect syntax highlighting with single quotes #260

whoami730 opened this issue Aug 17, 2023 · 7 comments · Fixed by #261

Comments

@whoami730
Copy link

val x = ''' + '"'
val y = 1 + 0

is highlighted incorrectly and ''' is assumed to start a string instead of being the string itself whereas

val x = '"' + '''
val y = 1 + 0

is correctly highlighted

@som-snytt
Copy link

''' is bad syntax.

3 |  val x = ''' + '"'
  |          ^
  |          empty character literal (use '\'' for single quote)

@whoami730
Copy link
Author

@som-snytt intellij seems to not be complaining - Guess I forgot to mention but this is scala 2.12.x

image

@whoami730
Copy link
Author

@som-snytt
Copy link

yes, it was a bug in 2.12. I remember the fix was deferred to a major release.

Actually github says 2.12.3. Oh wait, "Enforcement is under -Xsource:2.13." It was deprecated at 2.12.3, errors at 2.13.

https://scastie.scala-lang.org/2NAOmTP4SZeZHft2rRlYvQ

@nicolasstucki
Copy link
Contributor

We should add a special rule to allow ''' as a character. It does not seem to conflict with 2.13 nor 3.x.

@som-snytt
Copy link

The caution is that people accustomed to other languages have various assumptions about quote marks, such as that they introduce strings.

If you allow this syntax, then you must explain that ''' is not analogous to """.

Since the need is rare, it's not burdensome to write '\''. When constructing a string, prefer s"so-called 'fun'!".

@whoami730
Copy link
Author

i see @som-snytt thanks for the clarification - now that seems interesting and maybe we can swap usage of ''' to '\'' instead in our own codebase.

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.

3 participants