Skip to content

strings with backticks are misrecognized as template literals #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jpathy opened this issue Sep 23, 2019 · 3 comments · Fixed by #106
Closed

strings with backticks are misrecognized as template literals #104

jpathy opened this issue Sep 23, 2019 · 3 comments · Fixed by #106

Comments

@jpathy
Copy link

jpathy commented Sep 23, 2019

function foo() {
  a = '`sadsd`';
}
function bar() {
  a = '`sadas`';
}

Above program fails to parse.

@rhendric
Copy link
Contributor

My bug! I'm looking into it.

@jpathy
Copy link
Author

jpathy commented Sep 24, 2019

For the above program the following rule goes wrong:

<reg,divide> "}" @TemplateCharacters "`" { adapt (mkString' TemplateTailToken) }

I looked into the spec a bit and it seems that we need more lexical start codes than just reg, divide, see : https://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-lexical-grammar .

@rhendric
Copy link
Contributor

Yeah, I came to the same conclusion. Unfortunately, I think we also need more state shared between the parser and the lexer, because the lexer alone can't determine whether a given } is the delimiter between expression and template characters. I have a work in progress fix; I'm just in the process of polishing it up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants