Bug 149134 - Confusing error message when closing curly brace is missing in a template literal string
Summary: Confusing error message when closing curly brace is missing in a template lit...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-14 14:59 PDT by BJ Burg
Modified: 2015-09-14 15:18 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description BJ Burg 2015-09-14 14:59:54 PDT
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
Comment 1 Joseph Pecoraro 2015-09-14 15:18:09 PDT
> >>> 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)