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
syntax: $var#... is incorrectly parsed as a comment #1003
None of these contain comments, but the latter two examples get turned into comments (and this actually came up in practice; see bouk/babelfish#23). I'm not sure if it's just variable substitutions or if there are other circumstances where this incorrect parse happens.
Nice find - genuinely surprised that noone spotted this bug before. @bouk has the right idea, but unfortunately the fix isn't that easy. I'm investigating.
I spent quite a bit of time overthinking different ways to fix this, but I landed on something relatively simple: a small variation on @bouk's idea. It's not a complete fix, as two other cases still don't parse the way they should, but the cases you showed in this issue are all fixed.
Thanks for this! Would it be good to open an issue for the remaining cases? I haven't seen nix shell $(calculate-flake-ref)#... type constructions appear in a script yet, but I think more out of luck than anything else.
I left TODOs in the code as a personal reminder, but please feel free to open another issue if you think you'll run into it soon. Particularly if you already have any real example :)
Activity
bouk commentedon May 23, 2023
Seems like adding a
spacedcheck here is all that's needed:sh/syntax/lexer.go
Line 272 in 9e323b8
mvdan commentedon May 30, 2023
Nice find - genuinely surprised that noone spotted this bug before. @bouk has the right idea, but unfortunately the fix isn't that easy. I'm investigating.
[-]`$var#...` in argument lists is parsed incorrectly[/-][+]syntax: `$var#...` is incorrectly parsed as a comment[/+]mvdan commentedon Jun 10, 2023
I spent quite a bit of time overthinking different ways to fix this, but I landed on something relatively simple: a small variation on @bouk's idea. It's not a complete fix, as two other cases still don't parse the way they should, but the cases you showed in this issue are all fixed.
emilazy commentedon Jun 13, 2023
Thanks for this! Would it be good to open an issue for the remaining cases? I haven't seen
nix shell $(calculate-flake-ref)#...type constructions appear in a script yet, but I think more out of luck than anything else.mvdan commentedon Jun 14, 2023
I left TODOs in the code as a personal reminder, but please feel free to open another issue if you think you'll run into it soon. Particularly if you already have any real example :)
emilazy commentedon Jun 14, 2023
I'll wait to run into it :)
bouk commentedon Jun 15, 2023
@mvdan if you cut a release I'll update babelfish!
mvdan commentedon Jun 18, 2023
done :)
syntax: don't parse `$foo#bar` as a comment