Skip to content

Multiline strings should not allow backslashes to count as whitespace on first line. #19514

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
lrhn opened this issue Jun 18, 2014 · 2 comments
Closed
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Jun 18, 2014

The multiline spec changed at some point to allow backslashes before whitespace characters on the first line, and still ignore the first line.

I see not need for this complication, and I think it should be removed again.

I can understand the wish to have a single newline at the start of a multiline string not count, so all the lines of the multiline string start at the same offset.

I can understand allowing invisible whitespace before the newline, because it's impossible to see and having it change your behavior would be bad.

I see absolutely no need for allowing visible backslashes. These characters are NOT part of the string, there is no need or even rationale for "string escaping" to work. If anything, if string escaping is allowed, I would expect the line to be part of the string proper.

What was the reason for making this change?

See also issue #14073 (which includes the text from before allowing backlashes) - we haven't specified what the "first line" of a string is, because we haven't specified what a "line" is in Dart source, and it isn't obvious.

If we change the NEWLINE production to allow "CR NL" as a single line terminator (which implementations already do, and will keep doing), then the WHITESPACE production no longer specifies single characters, and the text needs rewriting anyway. Is the sequence BACKSLASH CR BACKSLASH NL part of the "first line of whitespace"?

@gbracha
Copy link
Contributor

gbracha commented Jun 30, 2014

Not sure we want to tamper with the standard over this kind of stuff, but we can take a look.


Set owner to @gbracha.
Added Accepted label.

@lrhn lrhn added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Jun 30, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@lrhn
Copy link
Member Author

lrhn commented Apr 9, 2025

Language repo issue: dart-lang/language#3228

@lrhn lrhn closed this as completed Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants