marko-js / marko

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

DevX: Incorrect error message when there are mismatched parentheses and brackets #1329

Open ccinelli opened 5 years ago

ccinelli commented 5 years ago

Marko Version: 4.16..0

Error:

Mismatched group. A ")" character was found when "{" was expected.at line 17 col 5

Code:

style.less {
    .aclass {
        color: #000;
    }
    .aclass1 {
        color: #000;
    }
    .aclass2 {
        color: #000;
    }
    .aclass3 {
        color: #000;
    }
}

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

    //More stuff
    if (this.state.v)) { // Error is here!!!!
    }
    this.anothervar = {
        what: 3
    };
  }
  onLanguageSelect() {
    const el = this.getEl("languageSelect");
    const selected = el.options[el.selectedIndex].value;
    this.emit("select-language", selected);
  }
}

<div>
</div>

Expected Behavior

The error should point at ))

Actual Behavior

Mismatched group. A ")" character was found when "{" was expected.at line 17 col 5

Steps to Reproduce

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

dominikstoetter commented 5 years ago

hey, i just stumbled across your issue and had a hard time figuring out what your problem was. If i understood correctly you are pointing out, that the error points to the line where class is defined. But the actuall error happens at the if condition that has a unnecessary closing )?