nushell/crates/nu-parser/tests
Yash Thakur b1e591f84c
Fix unterminated loop in parse_record (#15246)
Fixes #15243

# Description

As noted in #15243, a record with more characters after it (e.g.,
`{a:b}/`) will cause an OOM due to an infinite loop, introduced by
#15023. This happens because the entire string `{a:b}/` is lexed as one
token and passed to `parse_record`, where it repeatedly lexes until it
hits the closing `}`. This PR detects such extra characters and reports
an error.

# User-Facing Changes

`{a:b}/` and other such constructions will no longer cause infinite
loops. Before #15023, you would've seen an "Unclosed delimiter" error
message, but this PR changes that to "Invalid characters."

```
Error: nu::parser::extra_token_after_closing_delimiter

  × Invalid characters after closing delimiter
   ╭─[entry #5:1:7]
 1 │  {a:b}/
   ·       ┬
   ·       ╰── invalid characters
   ╰────
  help: Try removing them.
```

# Tests + Formatting

# After Submitting
2025-03-05 21:02:03 +01:00
..
test_lex.rs 14523 all comments should be prefixed with space tab or be beginning of token (#14616) 2024-12-25 21:31:51 +08:00
test_parser_unicode_escapes.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
test_parser.rs Fix unterminated loop in parse_record (#15246) 2025-03-05 21:02:03 +01:00