Bug 149134
Summary: | Confusing error message when closing curly brace is missing in a template literal string | ||
---|---|---|---|
Product: | WebKit | Reporter: | Blaze Burg <bburg> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | ggaren, gskachkov, joepeck, saam, ysuzuki |
Priority: | P2 | ||
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Blaze Burg
STEPS TO REPRODUCE:
Here's a test case that runs in the JSC shell:
>>> var foo = 123; var bar = `aaa bbb '${typeof foo'.`; 42;
Unexpected EOF:1
NOTES:
A useful error message occurs in this use case:
>>> var foo = 123; var bar = `aaa bbb '${typeof foo ccc'.`; 42;
Unexpected identifier 'ccc'. Expected a closing '}' following an expression in template literal.:1
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Joseph Pecoraro
> >>> var foo = 123; var bar = `aaa bbb '${typeof foo'.`; 42;
There are a couple interesting things here.
(1) The error comes from attempting to start parsing the nested template string:
This is valid: ` ... ${ ... `nested` }`
In the above, the nested template is `; 42;<EOF>`.
(2) We could have errored out sooner, in cases like:
foo.' (tokenizes a string)
foo.` (tokenizes a template string)