Skip to content
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

Update operators.md #1737

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jesper-olsen
Copy link
Contributor

logical not - higher precedence than and/xor/or, comparison.

logical not - higher precedence than and/xor/or, comparison.
@fdncred
Copy link
Collaborator

fdncred commented Jan 9, 2025

Either I'm not following what this PR is supposed to do, or it's just not right. If you do help operators | sort-by precedence -r the order is correct in our current documentation.

@jesper-olsen
Copy link
Contributor Author

Take the expression "not true and false"

If "not" has lower precedence than "and" then it is equivalent to

not (true and false) = not false = true

if "not" has higher precedence than and, then it it is equivalent to

(not true) and false = false and false = false

The shell - like most other languages - implements the latter case. So the documentation
is wrong. "not" has the highest precedence of all the boolean operators.

@fdncred
Copy link
Collaborator

fdncred commented Jan 9, 2025

ok, but then our help operators command and code that generates it must be wrong too. I'm not sure if 0 was hard coded for not or if it is system generated. I haven't looked.

@sholderbach
Copy link
Member

Related issue already on nushell/nushell#13675

@fdncred
Copy link
Collaborator

fdncred commented Jan 9, 2025

I thought this issue sounded familiar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants