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

Triple-quoted strings treated an expressions in macros #2682

Closed
dcjones opened this issue Mar 26, 2013 · 2 comments · Fixed by #11815
Closed

Triple-quoted strings treated an expressions in macros #2682

dcjones opened this issue Mar 26, 2013 · 2 comments · Fixed by #11815
Labels
parser Language parsing and surface syntax status:help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@dcjones
Copy link
Contributor

dcjones commented Mar 26, 2013

macro foo(arg)
    println(typeof(arg))
end

@foo("hello")
@foo("""hello""")

The first call to foo is ASCIIString the second is Expr. This prevents triple-quoted strings from being used as format strings in printf, among other things.

@JeffBezanson
Copy link
Sponsor Member

Yes, I'd say the indentation processing should be moved to the parser like interpolation was.

ivarne added a commit to ivarne/julia that referenced this issue Feb 18, 2014
This is a temporary hack for JuliaLang#2682, but the proper fix would be to fix
the parser to not emit macroall to the AST for triple quoted strings.

See: https://groups.google.com/forum/#!topic/julia-users/U1shoGwnCCQ
ivarne added a commit to ivarne/julia that referenced this issue Feb 18, 2014
This is a temporary hack for JuliaLang#2682, but the proper fix would be to fix
the parser to not emit macroall to the AST for triple quoted strings.

This commit also includes a ugly hack that will error when it is time to
remove this fast fix.

See: https://groups.google.com/forum/#!topic/julia-users/U1shoGwnCCQ
@ivarne ivarne added the status:help wanted Indicates that a maintainer wants help on an issue or pull request label Jan 2, 2015
@ivarne
Copy link
Sponsor Member

ivarne commented Jan 2, 2015

Marking this as "up for grabs", because it is a pretty annoying issue, and if we are going to fix it, we don't want people to write workaround solutions.

As far as I understand the reason for the whole mstr stuff for triple quoted strings is because we want some special de-indentation behaviour that we have implemented in triplequoted() base/string.jl:1039. It was easier to just emit @mstr("triple quoted string") than to implement triplequoted in C or scheme, so the current behaviour should be considered a temporary workaround.

Is this a correct work description?

@jakebolewski jakebolewski added the parser Language parsing and surface syntax label Apr 2, 2015
nolta added a commit that referenced this issue Jun 23, 2015
Strip out triple-quoted string indentation in the parser, instead of
using the mstr macro.

Also, no longer treat tabs as 8 spaces. Instead, remove the longest
common prefix of spaces and tabs.

Fixes #2682
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax status:help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants