mirror of
https://github.com/nushell/nushell.git
synced 2025-05-16 16:04:30 +02:00
# Description Zyphys found that when parsing `{...{}, ...{}, a: 1}`, the `a:` would be considered one token, leading to a parse error ([Discord message](https://discord.com/channels/601130461678272522/614593951969574961/1336762075535511573)). This PR fixes that. What would happen is that while getting tokens, the following would happen in a loop: 1. Get the next two tokens while treating `:` as a special character (so we get the next field key and a colon token) 2. Get the next token while not treating `:` as a special character (so we get the next value) I didn't update this when I added the spread operator. With `{...{}, ...{}, a: 1}`, the first two tokens would be `...{}` and `...{}`, and the next token would be `a:`. This PR changes this loop to first get a single token, check if it's spreading a record, and move on if so. Alternatives considered: - Treat `:` as a special character when getting the value too. This would simplify the loop greatly, but would mean you can't use colons in values. - Merge the loop for getting tokens and the loop for parsing those tokens. I tried this, but it complicates things if you run into a syntax error and want to create a garbage span going to the end of the record. # User-Facing Changes Nothing new |
||
---|---|---|
.. | ||
mod.rs | ||
test_bits.rs | ||
test_cell_path.rs | ||
test_commandline.rs | ||
test_conditionals.rs | ||
test_config_path.rs | ||
test_config.rs | ||
test_converters.rs | ||
test_custom_commands.rs | ||
test_engine.rs | ||
test_env.rs | ||
test_help.rs | ||
test_hiding.rs | ||
test_ide.rs | ||
test_iteration.rs | ||
test_known_external.rs | ||
test_math.rs | ||
test_modules.rs | ||
test_parser.rs | ||
test_ranges.rs | ||
test_regex.rs | ||
test_signatures.rs | ||
test_spread.rs | ||
test_stdlib.rs | ||
test_strings.rs | ||
test_table_operations.rs | ||
test_type_check.rs | ||
tests.rs |