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 affects explicitly written tabs (\t) #7165

Closed
mbauman opened this issue Jun 7, 2014 · 2 comments
Closed
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@mbauman
Copy link
Member

mbauman commented Jun 7, 2014

This caught me by surprise. Explicitly written whitespace escape characters in triple-quoted strings are treated no differently than the actual leading whitespace. Given its implementation as a macro, I can see why this is currently unavoidable, but it is very surprising:

julia> """\t""" == "\t"
true

julia> """
       \t""" == "\t"
false

julia> """
       foo
       \tbar""" == "foo\n\t\bar"
false

julia> """
       foo
       \tbar""" == "foo\n" * " "^8 * "bar"
true

julia> """
       foo
       bar\t""" == "foo\nbar\t"
true

Or a real example — I had to protect the tab within an interpolation.

@JeffBezanson
Copy link
Member

Wow. Interestingly:

julia> """
       a
        b
       """
"a\n b\n"

It looks like this case behaves as you'd expect: common leading whitespace is stripped, but the extra space before the b survives. But writing a tab instead of a space:

julia> """
       a
       \tb
       """
"a\n        b\n"

gives 8 spaces instead of the tab character. Doesn't seem right.

@StefanKarpinski
Copy link
Member

Well, that's certainly a bug.

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

3 participants