qfox/ZeParser — pull request #8 by kitcambridge (2011-12-24 13:50:07+00:00)
Title: Parser State Leakage for `switch` and `try` Statements

This example is valid; however, because the parser sets the `stack.parsedSwitchDefault` property for the first `switch` and doesn't reset it before parsing the second `switch`, it chokes when parsing the `default: bar;` clause.

```js
switch(x){ default: foo; break; case x: break; } switch(y){ default: bar; break; case y: break; }
```

This example is invalid, but the parser doesn't reset the `stack.tryHasCatchOrFinally` property after parsing the first `try...catch` block. As such, the example parses with no errors.

```js
try { foo(); } catch (e) {} try { bar(); }
```

I've tentatively patched this by deleting the `parsedSwitchDefault` and `tryHasCatchOrFinally` properties after each statement is parsed, but I'm not sure if this would impact the AST in any way. The unit tests pass, but I'm still not fully certain if this is safe to apply. What do you think?