Lexer still tries to produce tokens for non es3 keywords in es3 compatibility mode

VERIFIED WONTFIX

Status

Tamarin
Self-hosting compiler (ESC)
VERIFIED WONTFIX
10 years ago
7 years ago

People

(Reporter: Matthieu Riou, Unassigned)

Tracking

unspecified
x86
Linux
Bug Flags:
flashplayer-triage +

Details

Attachments

(1 attachment)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1
Build Identifier: changeset 618

When starting the ESC interpreter with the -es3 parameter, for Ecmascript 3 compatibility, all definitions of properties starting with 'is' produce a SyntaxError. The REPL or the direct interpreter (passing a file) behave in the same way.

Reproducible: Always

Steps to Reproduce:
1. Start the ESC interpreter
2. Execute something like "var foo = {foo: 1}" or "var foo={}; foo.isFoo = 1;"

Actual Results:  
SyntaxError: (repl):1: String or identifier required, found is
SyntaxError: (repl):1: Expecting semicolon or newline, found Foo

Expected Results:  
Expression should get evaluated properly.
(Reporter)

Comment 1

10 years ago
I've debugged this a bit and I think I found the root of the problem. In lex-scan.es, anytime there's a keyword that's not in es3 that has to handled, there's a specific condition. For example for the 'is' keyword:

case 115: /* Char::s */
  if (!ESC::flags.es3_keywords && !(notPartOfIdent[src.charCodeAt(curIndex+1)]))
    break bigswitch;
  curIndex += 1;
  return Token::Is;

It seems to me that the test is wrong as if we're in es3 compatibility mode, we *don't* want this token to be produced. Additionally if the next token is not a blank, it shouldn't be produced either (if I understand correctly what notPartOfIdent does). So I think the test should really be:

  if (ESC::flags.es3_keywords || !(notPartOfIdent[src.charCodeAt(curIndex+1)]))
    break bigswitch;

Changing the code this way makes it work for me and doesn't break the ESC compilation. I've had to fix this for the 'is' and the 'type' keyword so I can provide a patch for these. But I think that all these conditions should be updated (I can provide a patch too if you agree).
Summary: SyntaxError on object definitions with is prefixed property in ES3 compatibility mode → Lexer still tries to produce tokens for non es3 keywords in es3 compatibility mode
(Reporter)

Comment 2

10 years ago
Created attachment 334627 [details] [diff] [review]
Patch to fix es3 compatibility mode switch in lexer for 'if' and 'type' keywords
(Reporter)

Comment 3

10 years ago
Any chance of somebody looking at this?

Updated

9 years ago
Flags: flashplayer-triage+
Flags: flashplayer-qrb?

Updated

9 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → WONTFIX

Updated

9 years ago
Status: RESOLVED → VERIFIED

Updated

7 years ago
Flags: flashplayer-qrb?
You need to log in before you can comment on or make changes to this bug.