Skip to content

Better error message when the ; is missing at the end of class definition #4

@michaliskambi

Description

@michaliskambi

The following snippet

let hudObject = {
  // imagine a lot of content here :)
  xx1: 1,
  xx2: 2,
  xx3: 3,
  xx4: 4,
  xx5: 5,
  xx6: 6,
  xx7: 7,
  xx8: 8,
  xx9: 9,
  xx10: 10,
  xx11: 11,
  xx12: 12,
  xx13: 13,
  xx14: 14,
  xx15: 15,
  xx16: 16
}

return hudObject;

fails to parse with error:

[Exception(EPOCASyntaxError["poca/hud.poca"):2,15]: Precedence level overflow

A better error message would be helpful, pointing that return right after } is not correct.

Right now the

  • line number (2) points to the beginning of statement (not to the line where } or return are)
  • and the message is not obvious :) -- what is wrong with "precedence level" here.

I tested what JS reports for this, but it seems that missing ; is actually allowed. That is,

function foo()
{
let hudObject = {
  xx1: 1,
  xx2: 2,
  xx3: 3,
  xx4: 4,
  xx5: 5,
  xx6: 6,
  xx7: 7,
  xx8: 8,
  xx9: 9,
  xx10: 10,
  xx11: 11,
  xx12: 12,
  xx13: 13,
  xx14: 14,
  xx15: 15,
  xx16: 16
}

return hudObject;
}

works OK in a browser (Firefox) console and https://runjs.app/play .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions