Skip to content

Invalid JS: Compiler emits invalid JS when throw followed by if or for #3709

@epidemian

Description

@epidemian

This seemingly valid CS code:

throw if pedantic 
  new FatalError
else
  new ResumableError

Compiles to invalid JS:

throw if (pedantic) {
  new FatalError;
} else {
  new ResumableError;
};

I say seemingly valid because the same thing works for a function call:

raise = (e) -> throw e
raise if pedantic 
  new FatalError
else
  new ResumableError
var raise;

raise = function(e) {
  throw e;
};

raise(pedantic ? new FatalError : new ResumableError);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions