Reduce phase mismatches in scoped transform
Reduce phase mismatches in scoped transform

When looking up definitions in the static scope of a `ScopedExprTransform` it is not always possible to see the value at the current phase (i.e. after `StaticOptimizer` vs after `Parser` at the moment; we do not have more phases yet). This is a general problem in any language that allows recursive references in definitions.

Previously we used the simplest possible implementation in `ScopedExprTransform`: All definitions that are made together (e.g. in a single `local` expression) are stored in the scope at the same time (using their value after the previous phase), and then they are evaluated to provide an improved scope in which the body of the `local` can see them with the updated values after the current phase. This prevents full optimization in cases like this:

```
local a = 1,
      b = a,
      c = b;
c
```

When the rhs of `c` is optimized, the scope still contains `b = a` even though `a` has already been inlined (`b = 1`).

With this PR we do the next better thing: Update the scope incrementally to allow back-references to see the current phase.

Note that `a`, `b` and `c` are all allowed to refer to each other and they may be defined in an arbitrary order. In these cases we can still miss some optimizations, but supporting forward references would require lazy evaluation of scopes and recursion detection. In practice most references that benefit from these optimizations are expected to go backwards and we want to keep it simple.

databricks/sjsonnet,databricks/sjsonnet