Bug 162794
| Summary: | Find a way to make error messages better w.r.t arrow functions | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Saam Barati <saam> |
| Component: | JavaScriptCore | Assignee: | Saam Barati <saam> |
| Status: | NEW | ||
| Severity: | Normal | CC: | benjamin, fpizlo, ggaren, gskachkov, jfbastien, keith_miller, mark.lam, msaboff, oliver, ticaiolima, ysuzuki |
| Priority: | P2 | ||
| Version: | WebKit Local Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Saam Barati
Currently, this is a hard problem, because we parse the parameters both under non-parameter production, and then under the the parameter production. If both parses fail due to an error, it's difficult to tell which error message we should use.
For example:
let x = (a, ...a) => {}
We first parse (a, ...a) under non parameter list production. This causes an unexpected token "...".
Then we parse under the parameter list rule, and it produces "duplicate parameter" error. However, in
the general case, it's difficult to tell at this point which is the more legitimate error. I think to solve
this, we'd want a mode to parse the parameters fully and not to bail for errors that are created in the parsing
of the parameters themselves (but it would bail for parsing recursively). This means, it wouldn't bail for
duplicates, etc, and then we could see if the token after such a parse is "=>", if it is, we use the error
message from that parse, otherwise, we use the error message from the non-parameter parse.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |