Skip to content

Better error message when ; is mistakenly in the middle of class definition #5

@michaliskambi

Description

@michaliskambi

Mistakenly placing ; in the middle of class definition, like this:

let hudObject = {
  bbb: {
    x: 1
  },

  updateStep: function(deltaTime) {
  };

  aaa: function() {
  }
};

puts("HUD object loaded");

makes an error

[Exception(EPOCASyntaxError["poca/hud.poca"):8,2]: Bad hash initializer

Can we improve the message, to make it clearer that the syntax is incorrect, ; is unexpected here?

Looking at what JS does in this situation:

  1. Firefox JS engine answers

    Uncaught SyntaxError: missing } after property list
    note: { opened at line 1, column 17
    
  2. https://runjs.app/play answers even better, pointing to the right solution:

    SyntaxError: Unexpected token, expected "," (7:3)
    

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