Skip to content

Nodes: while with empty block is inconsistent with empty-block for #2446

@michaelficarra

Description

@michaelficarra
  • for with single-expression block containing undefined:

    $ coffee -be 'console.log (for a in [0, 1, 2, 3] then undefined)'
    [ undefined, undefined, undefined, undefined ]
    
  • for with empty block:

    $ coffee -be 'console.log (for a in [0, 1, 2, 3] then)'
    []  
    
  • while with single-expression block containing undefined:

    $ coffee -be 'i = 4; console.log (while i-- then undefined)'
    [ undefined, undefined, undefined, undefined ]
    
  • while with empty block:

    $ coffee -be 'i = 4; console.log (while i-- then)'
    undefined
    

The value of a for or while should always be a list. The behaviour of while with an empty block should change to produce an empty list so that it is consistent with for.

edit: an alternative (which I would actually prefer) would be to change the behaviour of the empty-block forms to match the forms with an undefined expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions