-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Parsing issue with = symbol #5806
Copy link
Copy link
Closed
Labels
A:parserIssues related to parsingIssues related to parsingcategory:bugSomething isn't workingSomething isn't workingstatus:investigatethis requires investigationthis requires investigation
Milestone
Description
Describe the bug
It seems in certain scenarios, when the = symbol is followed by any alpha-numerical character, the nu parser gives unexpected results.
I noticed this behaviour, when running my nu scripts after updating to 0.64.0 so this might be a regression.
How to reproduce
I think this is easiest explained with some example code:
def main [] {
assert-is-a { "" } string
assert-is-a { "=" } string
assert-is-a { "-" } string
assert-is-a { "-=" } string
assert-is-a { "-=-" } string
assert-is-a { "=-" } string
assert-is-a { [""] } list<string>
assert-is-a { ["="] } list<string>
assert-is-a { ["-"] } list<string>
assert-is-a { ["-="] } list<string>
# error: unknown command
#assert-is-a { ["-=-"] } list<string>
#assert-is-a { ["=-"] } list<string>
#assert-is-a { ["=-"] } list<string>
assert-is-a { ["= "] } list<string>
assert-is-a { [ "="] } list<string>
assert-is-a { ["=" ] } list<string>
assert-is-a { [ "=" ] } list<string>
assert-is-a { [ "=OK" ] } list<string>
}
def assert-is-a [
code: closure # some nu expression
expected_type: string # expected nu type of given expression, as printed by `describe`
] {
let span = (metadata $code).span;
let actual_type = ( do $code | describe )
if $actual_type == $expected_type {
echo $"(char sun)\t(ansi green_bold)OK(ansi reset)\t($actual_type)"
} else {
error make {
msg: $"(char cloud)\t(ansi red_bold)FAIL(ansi reset)",
label: {
text: $"expected a `($expected_type)` but got a `($actual_type)`",
start: $span.start,
end: $span.end
}
}
}
}Uncomment the commented out assertions to provoke the error.
Notice how the various positions of whitespace seem to affect the result.
Expected behavior
I expect the nushell syntax to be whitespace-insensitive (except for newlines), so that ["=a"] and [ "=a" ] mean the same thing.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.64.0 |
| branch | main |
| commit_hash | cfe4eff |
| build_os | windows-x86_64 |
| build_target | x86_64-pc-windows-msvc |
| rust_version | rustc 1.61.0 (fe5b13d68 2022-05-18) |
| cargo_version | cargo 1.61.0 (a028ae42f 2022-04-29) |
| pkg_version | 0.64.0 |
| build_time | 2022-06-16 10:49:43 +02:00 |
| build_rust_channel | debug |
| features | default, trash, which, zip |
| installed_plugins | gstat |
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A:parserIssues related to parsingIssues related to parsingcategory:bugSomething isn't workingSomething isn't workingstatus:investigatethis requires investigationthis requires investigation