CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Empty catch block disallowed

Open heartsentwined opened this issue 12 years ago • 3 comments

This is compiling fine:

try
  foo
catch e
  bar
baz

However, this throws a syntax error:

try
  foo
catch e
  # do nothing
baz
Syntax error on line 9, column 1: unexpected 'b' (\u0062)
06 :   foo
07 : catch e
08 :   # do nothing
09 : baz
^^ :~^
10 : 

Is this a feature, or a bug?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/825311-empty-catch-block-disallowed?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

heartsentwined avatar Apr 22 '13 23:04 heartsentwined

Current workaround is to pass just about any "dummy" statement in the catch block:

try
  foo
catch e
  '' # do nothing
baz
try
  foo
catch e
  true # do nothing
baz

heartsentwined avatar Apr 22 '13 23:04 heartsentwined

It's a bug.

michaelficarra avatar Apr 22 '13 23:04 michaelficarra

@michaelficarra same happens to other structures too, e.g.

if condition
  # TODO - to be implemented
else 
  return false

would throw an error at the # TODO line

heartsentwined avatar Oct 31 '13 17:10 heartsentwined