nushell/crates/nu-parser/src
Mango The Fourth d0e0701a88
fix: fix lexing of comments, such that a#b becomes a coherent Item (#8151)
# Description

Previously `nix run nixpkgs#hello` was lexed as `Item, Item, Item,
Comment`, however, `#hello` is *not* supposed to be a comment here and
should be parsed as part of the third `Item`.

This change introduces this behavior by not interrupting the parse of
the current token upon seeing a `#`.

Thank you so much for considering this, I think many `nix` users will be
grateful for this change and I think this will lead to more adaptation
in the ecosystem.

- closes #8137 and #6335 

# User-Facing Changes

- code like `somecode# bla` and `somecode#bla` will not be parsed as
`somecode, comment` but as `somecode#bla`, hence this is a breaking
change for all users who didn't put a space before a comment introducing
token (`#`)

# Tests + Formatting

I've added tests that cover this behavior in `test_lex.rs`

- [x] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass

# After Submitting

> If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.

I think this is expected behavior in most other shells, so the
documentation was lacking for not documenting the unexpected behavior
before and hence now is automatically more complete >D
2023-02-22 12:59:47 +00:00
..
deparse.rs Use variable names directly in the format strings (#7906) 2023-01-29 19:37:54 -06:00
errors.rs simplify parse_expression function code. (#8149) 2023-02-22 12:14:20 +00:00
eval.rs Use variable names directly in the format strings (#7906) 2023-01-29 19:37:54 -06:00
flatten.rs Support redirect err and out to different streams (#7685) 2023-01-12 10:22:30 +01:00
known_external.rs Fix command name lookup for known externals (#7830) 2023-01-22 21:40:18 +02:00
lex.rs fix: fix lexing of comments, such that a#b becomes a coherent Item (#8151) 2023-02-22 12:59:47 +00:00
lib.rs Small parser refactors (#7568) 2022-12-22 13:41:44 +02:00
lite_parser.rs Fix multi-line redirection inside a block (#7808) 2023-01-23 06:32:56 +13:00
parse_keywords.rs Make plugin commands support examples. (#7984) 2023-02-08 16:14:18 -06:00
parser.rs fixes a def parsing bug with a default list (#8096) 2023-02-22 12:53:11 +00:00
type_check.rs allow different types of lists to be appended (#8157) 2023-02-22 12:53:36 +00:00