Skip to content

Not operator needs parentheses in if statement #92

@samarseneault

Description

@samarseneault

In a composite "if" statement combining expressions with a boolean operator, if the second expression contains a "not" operator, then the second expression must be surrounded by parentheses. Not doing so causes a compilation error (Syntax error: expected identifier, found logic not).

For example:

function init() {
    # This is invalid syntax and causes a compilation error
    if (1 and not 0) {
        log("hello")
    }

    # This is valid syntax
    if (1 and (not 0)) {
        log("hello")
    }
}

This requirement seems unintuitive when comparing to languages like Python, where the parentheses would not be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions