Skip to content

Lexer: Within inline if block, a throw that takes implicit object will split the object into multiple objects #3199

@KarlPurk

Description

@KarlPurk

I apologise if this has already been reported, I did search the issues but there are lots related to "throw". Also, this may not be an issue, but I wanted to double check anyway.

When throwing exceptions the following syntax does not compile correctly:

if 1 then throw
    type: 'a'
    msg: 'b'

The above coffeescript compiles to the following:

if (1) {
  throw {
    type: 'a'
  };
}

({
  msg: 'b'
});

In order for this to compile we must use one of the following variations:

if 1 then throw type: 'a', msg: 'b'

or

if 1 then throw {
    type: 'a'
    msg: 'b'
}

or

if 1 
    throw
        type: 'a',
        msg: 'b'

Is this intended? Or are we missing out on a nicer syntax for throwing exceptions?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions