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

string interpolation and escaping bug #100

Closed
StefanKarpinski opened this issue Jul 8, 2011 · 8 comments
Closed

string interpolation and escaping bug #100

StefanKarpinski opened this issue Jul 8, 2011 · 8 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@StefanKarpinski
Copy link
Member

julia> println("\\ $('x')")
 x

julia> println("\\ x")
\ x
@ghost ghost assigned StefanKarpinski Jul 8, 2011
@JeffBezanson
Copy link
Member

Might be my fault. In the parser I unescape \ and " in strings that will be passed to macros. I don't have any idea why I'm doing that.

@StefanKarpinski
Copy link
Member Author

Other symptoms:

julia> "\\\\"
"\\\\"

julia> S"\\\\"
"\\"


julia> "\\\""
"\\\""

julia> S"\\\""
"\""

@StefanKarpinski
Copy link
Member Author

I think that's what's going on: you should turn \" into " but not turn \\ into \. Leaving \" as-is is harmless w.r.t. standard escaping rules, however, since \" just decodes as ". This is sort of mind-numbing stuff. Not quite sure what the right course of action is.

@StefanKarpinski
Copy link
Member Author

Btw, I'm not sure about this at all. I'm still mulling over what the right thing to do here is.

JeffBezanson added a commit that referenced this issue Jul 9, 2011
@JeffBezanson
Copy link
Member

I changed the parser behavior and it seems to work, and all tests still pass. I can't imagine why the behavior I had before was the right thing. Unless we can figure that out, we seem to be ok now.

@JeffBezanson
Copy link
Member

Ah, there is the case of L"\"". I guess that should be a string of one quote character?
Then there is kind of a strange situation where you can't make a string of a single \ using L syntax. L"\" escapes the quote and is incomplete input, and L"\\" is two backslashes.

@StefanKarpinski
Copy link
Member Author

I'm kind of thinking that the behavior of d443299 is the best. True, you can't use L" to make just " or \, but I think that may be unavoidable. The simplest behavior to understand seems to be that L" always makes a string literal that's exactly what's between the opening and closing quotes — and \" is a way of indicating that an intervening " is not the closing one. I'm pretty sure you can't avoid at least having your escape character \ be inexpressible in L" strings — this is why escaping exists. The only question is whether we want the same to apply to " or not. The difference between \ and " is that \ will be the escape character no matter what quote syntax exists, whereas " is specific to this quoting form. If we implement L""" then " by itself won't be a special character anymore. However, I still think the policy of passing the literal contents through may be best.

JeffBezanson added a commit that referenced this issue Jul 9, 2011
This reverts commit 793b9a5.

Conflicts:

	src/julia-parser.scm
@JeffBezanson
Copy link
Member

OK finally settled :)

fredrikekre added a commit that referenced this issue Feb 26, 2021
$ git log --pretty=oneline --abbrev=commit 2b4bed9..6bb8306
6bb83068bd796c4890baaeb39628ff79a4979374 Stop the grace timer iff adding first handle (fix #99) (#102)
af6864d8872247faf2a402d6b2baca5cb74ab96e fix ssh_key_pass bug (fix #91) (#100)
KristofferC pushed a commit that referenced this issue Feb 26, 2021
$ git log --pretty=oneline --abbrev=commit 2b4bed9..6bb8306
6bb83068bd796c4890baaeb39628ff79a4979374 Stop the grace timer iff adding first handle (fix #99) (#102)
af6864d8872247faf2a402d6b2baca5cb74ab96e fix ssh_key_pass bug (fix #91) (#100)
KristofferC pushed a commit that referenced this issue Mar 2, 2021
$ git log --pretty=oneline --abbrev=commit 2b4bed9..6bb8306
6bb83068bd796c4890baaeb39628ff79a4979374 Stop the grace timer iff adding first handle (fix #99) (#102)
af6864d8872247faf2a402d6b2baca5cb74ab96e fix ssh_key_pass bug (fix #91) (#100)

(cherry picked from commit fb500b0)
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this issue May 4, 2021
…uliaLang#39833)

$ git log --pretty=oneline --abbrev=commit 2b4bed9..6bb8306
6bb83068bd796c4890baaeb39628ff79a4979374 Stop the grace timer iff adding first handle (fix JuliaLang#99) (JuliaLang#102)
af6864d8872247faf2a402d6b2baca5cb74ab96e fix ssh_key_pass bug (fix JuliaLang#91) (JuliaLang#100)
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this issue May 9, 2021
…uliaLang#39833)

$ git log --pretty=oneline --abbrev=commit 2b4bed9..6bb8306
6bb83068bd796c4890baaeb39628ff79a4979374 Stop the grace timer iff adding first handle (fix JuliaLang#99) (JuliaLang#102)
af6864d8872247faf2a402d6b2baca5cb74ab96e fix ssh_key_pass bug (fix JuliaLang#91) (JuliaLang#100)
staticfloat pushed a commit that referenced this issue Dec 23, 2022
$ git log --pretty=oneline --abbrev=commit 2b4bed9..6bb8306
6bb83068bd796c4890baaeb39628ff79a4979374 Stop the grace timer iff adding first handle (fix #99) (#102)
af6864d8872247faf2a402d6b2baca5cb74ab96e fix ssh_key_pass bug (fix #91) (#100)

(cherry picked from commit fb500b0)
Keno pushed a commit that referenced this issue Oct 9, 2023
avoid some internal methods and invalid objects
udesou pushed a commit to udesou/julia that referenced this issue Nov 22, 2023
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
Projects
None yet
Development

No branches or pull requests

2 participants