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

Not operator needs parentheses in if statement #92

Open
samarseneault opened this issue Jun 7, 2021 · 0 comments
Open

Not operator needs parentheses in if statement #92

samarseneault opened this issue Jun 7, 2021 · 0 comments

Comments

@samarseneault
Copy link
Collaborator

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.

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

No branches or pull requests

1 participant