New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete parser of boolean expressions ending with bracket #11982
Comments
I agree that this should produce a parse error. However, it was confusing to figure out because there are no brackets in your example. There are parentheses This has one extra closing parenthesis and it seems like it should produce an error, but does not. if ((sys | get host | get name) == Windows)) { echo "WINDOWS" } else { echo "NOT WINDOWS" }
^
|
-- should be removed and our parser should say that |
Ah, sorry, yeah, I'm calling everything brackets, but it is indeed parentheses But expression like:
This would produce |
I think |
…1982) (#12098) - Fixes issue #11982 # Description Expressions with unbalanced parenthesis [excess closing ')' parenthesis] will throw an error instead of interpreting ')' as a string. Solved he same way as closing braces '}' are handled. ![Screenshot 2024-03-06 at 14 53 46](https://github.com/nushell/nushell/assets/56027726/86834e47-a1e5-484d-881d-0e3b80fecef8) ![Screenshot 2024-03-06 at 14 48 27](https://github.com/nushell/nushell/assets/56027726/bb27c969-6a3b-4735-8a1e-a5881d9096d3) # User-Facing Changes - Trailing closing parentheses ')' which do not match the number of opening parentheses '(' will lead to a parse error. - From what I have found in the documentation this is the intended behavior, thus no documentation has been updated on my part # Tests + Formatting - Two tests added in src/tests/test_parser.rs - All previous tests are still passing - cargo fmt, clippy and test have been run Unable to get the following command run - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library ![Screenshot 2024-03-06 at 20 06 25](https://github.com/nushell/nushell/assets/56027726/91724fb9-d7d0-472b-bf14-bfa2a7618d09) --------- Co-authored-by: Noak Jönsson <noakj@kth.se>
Describe the bug
Following expression will evaluate incorrectly, without syntax error, even though syntax wise you have superfluous bracket at the end
I did few experiments, and it seems parser just ignores trailing brackets, even if you put tons of them
Interestingly enough, extra bracket will reverse result of expression inside.
I.e. my example above will be
NOT WINDOWS
even on windows systemFrom my observation parser seems to mind brackets, but it seems to be pretty lax about its number, resulting in expression to become incorrect or outright not making any sense
How to reproduce
Use above example in console
Expected behavior
Indicate error in case of invalid number of brackets at the end
Screenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: