adobe-research/mesh — pull request #84 by bhosmer (2013-06-14 23:10:55+00:00)
Title: Fix issue #83

The problem was that inlining was hiding a bug in the implementation
of ifelse(), which would cause an index out of bounds exception when
the default case was reached. Inliners of conditional code would cause
the expressions that produced lambda arguments for conditionals (e.g.
the 2nd and 3rd args of a call to if(), 2nd arg to a when(), 3rd arg
to a guard(), etc.) to be evaluated lazily rather than eagerly. In
cases where the expression is immediate, such as a lambda literal or
a ref, the two are indistinguishable, but in cases where nontrivial
computation is involved (such as indexing into a list, the situation
in ifelse()) the difference is observable and lazy evaluation may
avoid errors incorrectly. Inliners are now properly conservative.

(Note: current code fails to inline certain cases that are possible,
because it's not clear that they pay their way w.r.t. complexity. If
desired, the template for such cases is ForInliner(), where a local
block is created that evaluates the lambda-producing expression and
stores it to a local before proceeding.)

Also fixed the implementation of ifelse() to avoid the error (now
correctly produced with the original implementation whether inlining
is on or not).