marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.35k stars 643 forks source link

No error reported for wrong token ... just an irrelevant stack trace #1330

Closed ccinelli closed 5 years ago

ccinelli commented 5 years ago

Marko Version: 4.16.0

Screen Shot 2019-05-15 at 1 39 18 PM
Unable to load "/marko-language-guide/components/parent-child-communication/components/language-selector.marko.js": SyntaxError: Unexpected token const:
SyntaxError: Unexpected token const
    at i (https://markojs.com/try-online-async-00e01d07.js:432:1087)
    at .marko (https://markojs.com/try-online-async-00e01d07.js:432:2152)
    at Object.h [as loadFile] (https://markojs.com/try-online-async-00e01d07.js:432:392)
    at i (https://markojs.com/try-online-async-00e01d07.js:521:841)
    at l.<anonymous> (https://markojs.com/try-online-async-00e01d07.js:521:1049)
    at f (https://markojs.com/try-online-17ad1dd8.js:29:226)
    at l.emit (https://markojs.com/try-online-17ad1dd8.js:29:793)
    at c.exports.<anonymous> (https://markojs.com/try-online-async-00e01d07.js:434:1069)
    at f (https://markojs.com/try-online-17ad1dd8.js:29:226)
    at c.exports.emit (https://markojs.com/try-online-17ad1dd8.js:29:724)

Code:

style.less {
    .aclass {
        color: #000;
    }
}

class {
  onCreate() {
    this.state = {
        v : null
    }; 
  }
}

<div>
  $ // Error is below
  $ const a =23s2;
</div>

Expected Behavior

The error should point to the line with the incorrect token (23s2).

Actual Behavior

See error above

Steps to Reproduce

Copy the code in https://markojs.com/try-online

DylanPiercey commented 5 years ago

This particular issue was due to an error in parsing comments which was resolve here: https://github.com/marko-js/htmljs-parser/pull/71