Skip to content

Incorrect code generation with existential operator inside brackets #3309

@Diggsey

Description

@Diggsey

The following code will alert the value "true", when clearly the only two possible outputs of the "if" are the string or undefined. It seems like coffeescript doesn't properly understand the precedence rules for the javascript ternary operator. Removing the brackets from the condition will miraculously fix it...

f = -> true

result = if (f?()) then "THIS SHOULD BE ALERTED!"

alert result

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions