nushell/tests
Yash Thakur 1128fa137f
Fix spread operator lexing in records (#15023)
# 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
2025-02-11 09:51:34 -05:00
..
assets/nu_json Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
const_ Improve and fix filesize formatting/display (#14397) 2025-01-22 22:24:51 -08:00
eval Improve and fix filesize formatting/display (#14397) 2025-01-22 22:24:51 -08:00
fixtures fix(completion): dotnu_completion dir with space, expand tilde (#14983) 2025-02-02 07:54:09 -06:00
hooks Make Hooks fields non-optional to match the new config defaults (#14345) 2024-11-29 21:11:09 +00:00
modules don't include import path in args to aliased external commands (#14231) 2024-11-06 07:40:29 -06:00
overlays Fix missing required overlay error (#15058) 2025-02-10 16:27:50 +08:00
parsing Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
path Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
plugin_persistence Make plugin list read state from plugin registry file as well (#14085) 2024-10-20 23:12:57 +02:00
plugins Fix unstable test case: One time my windows report drive letter as lowercase (#14451) 2024-11-27 06:27:06 -06:00
repl Fix spread operator lexing in records (#15023) 2025-02-11 09:51:34 -05:00
scope Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
shell Enable nushell error with backtrace (#14945) 2025-02-06 22:05:58 +08:00
main.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00