You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strings beginning with quotes should not be interpreted as bare strings #13010
Not sure whether to call this a bug or feature request. I feel it's a bug, but I'm going to start with "enhancement" and a maintainer can change the tag if you agree.
I was changing a raw-string to a single-quoted string today, and I forgot to remove the trailing #.
>letgithub_pat='github_pat_11AHWYXA0DDyPvy...'## Note: Not a valid GitHub PAT, of course
The result, surprisingly, was a bare-string including the quotes and trailing #:
>$github_pat'github_pat_11AHWYXA0DDyPvy...'#
That, of course, caused the http get to fail authentication.
I was thinking this might be due to the raw-string parsing, but it turns out that any non-whitespace characters immediately following the closing quote will turn the quoted-string into a bare-string.
>'abc'abc>'abc'a'abc'a>"onetwo"3"onetwo"3
Except for raw-strings, which work as I'd expect:
>r#'abc'#abcError:nu::parser::unbalanced_delimiter×Unbalanceddelimiter.╭─[entry#42:1:1]1│r#'abc'#abc·─────┬─────·╰──unbalancedprefix# and postfix #╰────
Describe the solution you'd like
It seems to me that characters following a close-quote are almost certainly (as in my case) a syntax error and should result in an error condition.
Describe alternatives you've considered
I tend to prefer not receiving an error when there's a possibility that the syntax could be useful and intended, but in this case:
I can't see where it might be intended
If for some odd reason it was intended, we now have raw-strings, and those seem like a better (and safer) implementation.
Interesting. @WindSoilder any thoughts on this? I'm guessing we should be able to see an end # without a beginning r# and complain about it. Agreed that this seems related to raw_string_literals but may not be based on your other findings, which are definitely weird looking.
I'm guessing we should be able to see an end # without a beginning r# and complain about it.
But that would leave all the other trailing character-issues in place.
What I'm basically proposing is any string that starts with a single or double-quote, but doesn't end with one, should be an error, not a bare-string. Raw-strings do work like this, already. They're great - And thank you again for that syntax.
I've encountered it a couple of times, and it confused me, too. Strings have two completely separate semantics depending on how the quotes are balanced.
Activity
fdncred commentedon May 30, 2024
Interesting. @WindSoilder any thoughts on this? I'm guessing we should be able to see an end
#without a beginningr#and complain about it. Agreed that this seems related to raw_string_literals but may not be based on your other findings, which are definitely weird looking.NotTheDr01ds commentedon May 30, 2024
But that would leave all the other trailing character-issues in place.
What I'm basically proposing is any string that starts with a single or double-quote, but doesn't end with one, should be an error, not a bare-string. Raw-strings do work like this, already. They're great - And thank you again for that syntax.
kaathewisegit commentedon May 31, 2024
I've encountered it a couple of times, and it confused me, too. Strings have two completely separate semantics depending on how the quotes are balanced.
WindSoilder commentedon May 31, 2024
It makes sense to me, I can not see a case that we should interpreted it as bare strings.
Restrict strings beginning with quote should also ending with quote (n…