Skip to content

'not' operator precedence displayed wrong #13675

Closed

Description

@rayanamal

Describe the bug

Operators and their precedence values are given with the help operators command:
image

not operator precedence is given as 0. or precedence is 40.


~> if not (false) or (true) { print hello }

This prints hello. If or precedence was higher than not, it wouldn't print anything, since the evaluation order would be like the following:

~> if not ((false) or (true)) { print hello }

How to reproduce

Run the given command.

Expected behavior

help operators command to display the correct precedence.

Screenshots

No response

Configuration

key value
version 0.96.1
major 0
minor 96
patch 1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.80.1 (3f5fd8dd4 2024-08-06) (built from a source tarball)
cargo_version cargo 1.80.0 (376290515 2024-07-16)
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash
installed_plugins

Additional context

I feel there is a special reason I don't know for why nots precedence is 0 here.

Activity

  1. added
    status:needs-triage
    on Aug 23, 2024
  2. added
    category:documentation
    on Aug 23, 2024
  3. sholderbach commented on Aug 23, 2024

    @sholderbach
    Member

    Good catch. At the same time our handling of not (as the only unary operator) is kind of weird (due to how it may/may not behave similar to a command) so it may not have a consistent precedence, so worth a little digging.

  4. added
    A:syntax
    and removed
    status:needs-triage
    on Aug 23, 2024
  5. added this to the v0.103.0 milestone on Feb 13, 2025
  6. added a commit that references this issue on Feb 13, 2025
    62e56d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:syntaxcategory:documentation

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions