Skip to content

Invalid JS: [a?.b…] compiles to invalid JavaScript #4260

@maxnordlund

Description

@maxnordlund

I found this today, below is the reduced code to reproduce this error on coffeescript.org.

handler = (error) =>
  if error instanceof Error
    arr.push(error)
  else
    arr.push(error.data?.errors...)
  @showErrors = !!foo.length
var handler;

handler = (function(_this) {
  return function(error) {
    var ref;
    if (error instanceof Error) {
      arr.push(error);
    } else {
      // The loose if-statement is the error
      arr.push.apply(_this,       if ((ref = error.data) != null) {
        ref.errors;
      });
    }
    return _this.showErrors = !!foo.length;
  };
})(this);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions