Skip to content

Reject char literal of raw newline #8282

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

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Feb 11, 2020

Don't allow char literal to span a natural line
ending, but do allow '\u000A' to mean '\n'.
The spec was updated to reflect that meaning,
and the direction is to eliminate Unicode escapes
outside quotes.

Update the test rig so that // anypos-error can be
used to match any position, since the test cannot
be expressed on one line with a trailing comment.

Forward port of fix on 2.12.

scala/scala@d7547cb

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@som-snytt
Copy link
Contributor Author

Double checking that it's not possible to write the test with

val c = '// error
'

I noticed

scala> '//
1 |'//
  |^
  |symbol literal '// is no longer supported,
  |use a string literal "//" or an application Symbol("//") instead,
  |or enclose in braces '{//} if you want a quoted expression.

scala> x_//
1 |x_//
  |^^^^
  |Not found: x_

It's not obvious that these are different with respect to tokenization, except literal vs identifier.

Scala 2 had a ticket IIRC for double slash in a name. I can't find it.

@som-snytt
Copy link
Contributor Author

/rebuild

@som-snytt
Copy link
Contributor Author

Not sure how to communicate with do-bo.

The restart button on drone is disabled.

@OlivierBlanvillain
Copy link
Contributor

@som-snytt you can push an empty commit or rebase + force push

@som-snytt som-snytt force-pushed the forward/charlit branch 2 times, most recently from 62e5731 to 36a1a6a Compare February 26, 2020 00:49
@martijnhoekstra
Copy link
Contributor

Why not though?

@abgruszecki abgruszecki self-assigned this Mar 23, 2020
Don't allow char literal to span a natural line
ending, but do allow `'\u000A'` to mean `'\n'`.
The spec was updated to reflect that meaning,
and the direction is to eliminate Unicode escapes
outside quotes.

Update the test rig so that `// anypos-error` can be
used to match any position, since the test cannot
be expressed on one line with a trailing comment.
@som-snytt
Copy link
Contributor Author

Rebased and fixed conflict with whitespace change.

The controversial part is support for // anypos-error in tests for the edge case where the error comment alters the test.

@abgruszecki
Copy link
Contributor

Hey there, thanks for the PR!
Two questions:

  1. is there any specific reason why ''' is now invalid syntax when it was valid before? It seems to me rejecting char lit of raw newline doesn't require rejecting ''' as a valid char lit.
  2. is there any need for both anypos-error and a checkfile?

@som-snytt
Copy link
Contributor Author

som-snytt commented Apr 7, 2020

The scala 2 ticket and PR say the spec disallowed it, and the ticket quotes it, but I can't find it at the moment. (or after looking for a half hour)

scala/bug#10133
scala/scala#5629

The test rig requires the error comment? Everything that happened before the pandemic feels like a long time ago, and in fact I was getting sick that week, so I don't quite recall. The check file shows what error message was produced, not only that there was an error. My initial expectation was that the error comment would include the expected error text, perhaps as a regex.

@abgruszecki
Copy link
Contributor

I was a bit ill as well when the lockdowns hit. Hope everything's all right on your side.

Reg. the PR: I was under the impression that the test rig required either // error comments or checkfiles, not both at the same time; and ofc adhering to spec is a good reason for forbidding '''. Merging now.

@abgruszecki abgruszecki merged commit 33a6f9e into scala:master Apr 7, 2020
@som-snytt som-snytt deleted the forward/charlit branch April 15, 2020 05:38
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 this pull request may close these issues.

6 participants