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

Unindentation in triple-quoted strings affected by explicitly written newline (\n) #34105

Closed
goretkin opened this issue Dec 15, 2019 · 1 comment · Fixed by #35001
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior minor change Marginal behavior change acceptable for a minor release parser Language parsing and surface syntax

Comments

@goretkin
Copy link
Contributor

let str = "\n   yoyo"
        println("1: ")
        println("""begin line: interpolate:$str
        begin next line:""")
end

let str = "   yoyo"
        println("2: ")
        println("""begin line: interpolate:\n$str
        begin next line:""")
end

produces

1: 
begin line: interpolate:
   yoyo
begin next line:
2: 
begin line: interpolate:
   yoyo
        begin next line:

But I had expected both blocks of outputs under 1: and 2: to be the same. I did not expect "\n" (in the string) to be treated the same as \n (in the file) within a triple-quoted string.

(kind of dual error of #7165)

@StefanKarpinski StefanKarpinski added the bug Indicates an unexpected problem or unintended behavior label Dec 15, 2019
@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label Mar 3, 2020
@JeffBezanson
Copy link
Member

Yes, this is a bug. It happens because we do unescaping before unindenting. I ran into this fixing #34967, where the same bug prevents you from using escapes to write an invalid string with triple quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior minor change Marginal behavior change acceptable for a minor release parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants