jashkenas/coffee-script — Issue #1906: incorrect handling of parenthesized multi-line condition in if-statement
Author: loveencounterflow
Created: 2011-12-02 18:18:27+00:00
State: open

when i try to run

if ( null and
null and
null )
null

i succeed; but re-writing this as

if ( null
and null
and null )
null

then compilation will fail with `Unexpected 'INDENT'`. the two ways to write the same conditional expression
should be treated with no difference in logic or syntax.

relatedly, i couldn't get this code (translated from http://javascript.crockford.com/tdop/tdop.html, section "Functions") to compile:

if ( ( left.arity isnt "unary" or left.id isnt "function" ) and
left.arity isnt "name" and left.id isnt "(" and left.id isnt "&&" and left.id isnt "||" and left.id isnt "?" )
left.error "Expected a variable name."

without either putting the entire conditional expression into one long line or breaking it up into a series of nested `if` statements. in this case, the compiler complains with `Unexpected 'POST_IF'`. i would have distilled the exact point of failure from the code, but didn't manage to get something minimal that shows the same sympoms.