marijnh/acorn — pull request #95 by ConradIrwin (2014-04-17 19:39:09+00:00)
Title: [loose parser] Fix interpretation of `f."`

Before this the ast produced by parse_dammit crashed in the following code, as
Uglify correctly noticed that foo."" is invalid.

sample = 'f."';

loose = require('acorn/acorn_loose');
uglify = require('uglify-js');

out = new uglify.OutputStream();
ast = loose.parse_dammit(sample);
ast = uglify.AST_Node.from_mozilla_ast(ast);
ast.print(out);
// TypeError: Cannot call method 'toString' of undefined
// member_exp.computed = false && member_exp.property == ""

console.log(out.toString());

After this the round-tripped AST looks like: `t.✖;"";`, which is consistent
with how `foo.{` is parsed.

I also considered making it parse as t[""], but as this only turns up in the
wild when people try to use multiline strings, I felt it was better to be
obviously wrong.