amohanta / google-caja

Automatically exported from code.google.com/p/google-caja
0 stars 0 forks source link

Parser does not accept "for (a.k in x) { ... }" #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Parser does not accept a property as the key variable in a foreach, despite
the fact that JavaScript (at least Firefox) permits it. An example and the
stacktrace are pasted below. ECMA-262 section 12.6.4 specifies the syntax as --

  for ( <LeftHandSideExpression> in <Expression> ) <Statement>

     *   *   *   *   *

Parsing: for (a.k in x) { k; }

com.google.caja.lexer.ParseException: source:1+14 - 15: Expected ; not )
    at com.google.caja.lexer.TokenQueue.expectToken(TokenQueue.java:251)
    at com.google.caja.lexer.JsTokenQueue.expectToken(JsTokenQueue.java:69)
    at com.google.caja.parser.js.Parser.parseLoopOrSwitch(Parser.java:376)
    at
com.google.caja.parser.js.Parser.parseStatementWithoutLabel(Parser.java:481)
    at com.google.caja.parser.js.Parser.parseStatement(Parser.java:310)
    at com.google.caja.parser.js.Parser.parseTerminatedStatement(Parser.java:1175)
    at com.google.caja.parser.js.Parser.parse(Parser.java:266)
        ...

Original issue reported on code.google.com by ihab.a...@gmail.com on 11 Feb 2008 at 10:11

GoogleCodeExporter commented 9 years ago
Another testcase

For all o with no enumerable properties,
  var k == 3;
  for (k in o) {}
  assertEquals(3, k);

Original comment by mikesamuel@gmail.com on 12 Feb 2008 at 12:25

GoogleCodeExporter commented 9 years ago
Ignore last.  That was supposed to be attached to a different bug.

Original comment by mikesamuel@gmail.com on 12 Feb 2008 at 12:28

GoogleCodeExporter commented 9 years ago

Original comment by mikesamuel@gmail.com on 11 Mar 2008 at 5:35

GoogleCodeExporter commented 9 years ago

Original comment by mikesamuel@gmail.com on 18 Mar 2008 at 9:19