mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
prevent parser from parsing variables as units (#12378)
# Description Resolves #11274. ``` ~/CodingProjects/nushell> let day = 2; echo 0..<$day ╭───┬───╮ │ 0 │ 0 │ │ 1 │ 1 │ ╰───┴───╯ ~/CodingProjects/nushell> let kb = "jan"; echo 0..$kb Error: nu:🐚:type_mismatch × Type mismatch during operation. ╭─[entry #1:1:22] 1 │ let kb = "jan"; echo 0..$kb · ┬─┬─┬─ · │ │ ╰── string · │ ╰── type mismatch for operator · ╰── int ╰──── ``` # Tests + Formatting Relevant test added 🆙 --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
@ -1191,6 +1191,16 @@ mod range {
|
||||
|
||||
assert!(!working_set.parse_errors.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vars_not_read_as_units() {
|
||||
let engine_state = EngineState::new();
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
|
||||
let _ = parse(&mut working_set, None, b"0..<$day", true);
|
||||
|
||||
assert!(working_set.parse_errors.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user