mirror of https://github.com/lukechilds/node.git
Browse Source
This simplifies the logic that was in isSyntaxError, as well as the choice to wrap command input in parens to coerce to an expression statement. 1. Rather than a growing blacklist of allowed-to-throw syntax errors, just sniff for the one we really care about ("Unexpected end of input") and let all the others pass through. 2. Wrapping {a:1} in parens makes sense, because blocks and line labels are silly and confusing and should not be in JavaScript at all. However, wrapping functions and other types of programs in parens is weird and required yet *more* hacking to work around. By only wrapping statements that start with { and end with }, we can handle the confusing use-case, without having to then do extra work for functions and other cases. This also fixes the repl wart where `console.log)(` works in the repl, but only by virtue of the fact that it's wrapped in parens first, as well as potential side effects of double-running the commands, such as: > x = 1 1 > eval('x++; throw new SyntaxError("e")') ... ^C > x 3v0.11.7-release
isaacs
11 years ago
1 changed files with 53 additions and 62 deletions
Loading…
Reference in new issue