ractivejs/ractive — pull request #889 by Rich-Harris (2014-06-28 19:20:50+00:00)
Title: BREAKING CHANGE allows use of ~/foo to refer to root-level foo property (#570)

This PR implements support for #570 (not #580, as the commit message states) - it allows the use of `{{~/foo}}` references that *always* refer to the *root-level* property `foo`, even if non-root parent contexts have `foo` properties. Similar to ancestor references (`{{../../foo}}`) except that you don't need to keep track of how many levels deep you are.

This is a little bit opinionated, so I won't merge it straight away in case people have objections or alternative suggestions.

In the process of implementing this, it was necessary to address a hitherto undiscovered flaw in the parser - ordinarily it obeys [operator precedence](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence), but somehow the precedence got reversed in the case of postfix operators (including `~`, which is how this became apparent).

The side-effect of this was that the parser would try to match `~/foo` as a bitwise NOT expression before trying to match it as a root-level reference, which is the wrong way round (references are 'primary' and have higher priority than operators). Fixing this introduced another bug - `typeof foo` would be matched as a `typeof` reference followed by an illegal token - so the reference matcher now explicitly disallows keywords (such as `typeof`, but also `break, case, catch ... void, while, with` - full list [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Reserved_Words)).

The tl;dr of the previous two paragraphs is that **you can no longer use keywords as reference names within expressions**, if you were daft enough to do so previously. So no more

```html
{{ do ? "or do not" : "there is no" + try }}
```