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

\u001A does not work in triple quoted string literals #8712

Closed
scabug opened this issue Jul 9, 2014 · 4 comments
Closed

\u001A does not work in triple quoted string literals #8712

scabug opened this issue Jul 9, 2014 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 9, 2014

scala> "\u000A".map(_.toInt)
res7: scala.collection.immutable.IndexedSeq[Int] = Vector(10)

scala> """\u000A""".map(_.toInt)
res8: scala.collection.immutable.IndexedSeq[Int] = Vector(10)

scala> "\u001A".map(_.toInt)
res9: scala.collection.immutable.IndexedSeq[Int] = Vector(26)

scala> """\u001A""".map(_.toInt)
<console>:1: error: illegal character
       """\u001A""".map(_.toInt)
               ^
@scabug
Copy link
Author

scabug commented Jul 9, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8712?orig=1
Reporter: Denis Petrov (denis)
Affected Versions: 2.11.1

@scabug
Copy link
Author

scabug commented Jul 11, 2014

@som-snytt said:
Normally, with any quoting:

suend.scala:5: error: unclosed multi-line string literal
  Console println ("""\u001A""" map (_.toInt))
                   ^
suend.scala:5: error: illegal character
  Console println ("""\u001A""" map (_.toInt))
                           ^

or

suend.scala:6: error: illegal character
  Console println ("\u001A" map (_.toInt))
                         ^

And for example,

suend.scala:5: error: unclosed comment
  /* \u001a */
  ^

The behavior of SU (substitute for a bad char) kind of explains

      case SU => // strangely enough, Character.isUnicodeIdentifierPart(SU) returns true!
        finishNamed()

that is, because or despite the fact that

Character.isIdentifierIgnorable(SU)

Scala balks at the interloper.

If a fellow in a mask showed up in your room, would you say, "Oh, he might be Zorro or maybe Batman, I mustn't kick him out!"

Or perhaps, because he is ignorable, you settle deeper into your armchair and go on reading your novel.

This may not be something to advertize, but a workaround is to use interpolation, where scanning is subtly different because, you know, it's different code:

scala> val x = s"""\u001A"""
x: String = ?

@SethTisue SethTisue added this to the Backlog milestone Mar 2, 2018
@unkarjedy
Copy link

@martijnhoekstra Not actual since 2.13.2? scala/scala#8282

image

@martijnhoekstra
Copy link

martijnhoekstra commented Dec 25, 2020

Yes, fixed by scala/scala#8282

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

No branches or pull requests

4 participants