mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
Add did-you-mean suggestions for bitwise ops (#7252)
Continues work from #7251 to include the bitwise operations. Covers the C style conventions as well as the typo `bits-*` instead of `bit-*`
This commit is contained in:
parent
cbc7b94b02
commit
a9e6b1ec6b
1 changed files with 55 additions and 1 deletions
|
@ -4514,7 +4514,7 @@ pub fn parse_operator(
|
||||||
b"pow" => "pow",
|
b"pow" => "pow",
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
"Use '**' for exponentiation",
|
"Use '**' for exponentiation or 'bit-xor' for bitwise XOR.",
|
||||||
span,
|
span,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
@ -4553,6 +4553,60 @@ pub fn parse_operator(
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
b"&" => {
|
||||||
|
return (
|
||||||
|
garbage(span),
|
||||||
|
Some(ParseError::UnknownOperator(
|
||||||
|
"&",
|
||||||
|
"Did you mean 'bit-and'?",
|
||||||
|
span,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
b"<<" => {
|
||||||
|
return (
|
||||||
|
garbage(span),
|
||||||
|
Some(ParseError::UnknownOperator(
|
||||||
|
"<<",
|
||||||
|
"Did you mean 'bit-shl'?",
|
||||||
|
span,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
b">>" => {
|
||||||
|
return (
|
||||||
|
garbage(span),
|
||||||
|
Some(ParseError::UnknownOperator(
|
||||||
|
">>",
|
||||||
|
"Did you mean 'bit-shr'?",
|
||||||
|
span,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
bits @ (b"bits-and" | b"bits-xor" | b"bits-or" | b"bits-shl" | b"bits-shr") => {
|
||||||
|
return (
|
||||||
|
garbage(span),
|
||||||
|
Some(ParseError::UnknownOperator(
|
||||||
|
match bits {
|
||||||
|
b"bits-and" => "bits-and",
|
||||||
|
b"bits-xor" => "bits-xor",
|
||||||
|
b"bits-or" => "bits-or",
|
||||||
|
b"bits-shl" => "bits-shl",
|
||||||
|
b"bits-shr" => "bits-shr",
|
||||||
|
_ => unreachable!(),
|
||||||
|
},
|
||||||
|
match bits {
|
||||||
|
b"bits-and" => "Did you mean 'bit-and'?",
|
||||||
|
b"bits-xor" => "Did you mean 'bit-xor'?",
|
||||||
|
b"bits-or" => "Did you mean 'bit-or'?",
|
||||||
|
b"bits-shl" => "Did you mean 'bit-shl'?",
|
||||||
|
b"bits-shr" => "Did you mean 'bit-shr'?",
|
||||||
|
_ => unreachable!(),
|
||||||
|
},
|
||||||
|
span,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return (
|
return (
|
||||||
garbage(span),
|
garbage(span),
|
||||||
|
|
Loading…
Reference in a new issue