mirror of
https://github.com/nushell/nushell.git
synced 2025-05-12 22:14:26 +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 |
||
---|---|---|
.. | ||
assets/nu_json | ||
const_ | ||
eval | ||
fixtures | ||
hooks | ||
modules | ||
overlays | ||
parsing | ||
path | ||
plugin_persistence | ||
plugins | ||
repl | ||
scope | ||
shell | ||
main.rs |