adolfopa/racket-mustache — pull request #2 by brettg (2014-04-23 23:02:04+00:00)
Title: Partial env bug fixes

Currently `partial` passes `(current-env)` to `render` resulting in a new `struct:environment` with the old env in its `frames` field. This can cause errors inside `dict-ref` for the environment when it tries to call `dict:has-key?` on the wrapped environment, e.g. this happens when the partial references a name not in the original dict.

This fix changes `with-env` to just set any `struct:environment` directly to `current-env` instead of wrapping it in a new environment. The assumption is that the only place this should happen is while rendering a partial.

An alternative might be to implement `dict-has-key?` for `struct:environment` so that nested environments do not err but this seemed more straight forward.

(I'm not really sure why the `environment?` predicate doe not work on `obj` inside `with-env`, but it was returning `#f` for me on values that I knew were environments, hence using `object-name`.)