Lambda expressions don't introduce their own scope
An expression such as:
someRulename : x -> <map(\Plus(a,b) -> Plus(a,b) with aa := a; bb := b\)> [Plus(Num(1),Num(2)),Plus(Num(3),Num(4))]
will fail with an unexpected failure in the with clause. The error that occurs is that after the first expression (1+2) has been put through the lambda expression the variables aa and bb have been set and remain set when the second expression is put through the lambda expression. This can be observed by putting debug statements in between all parts of the with-clause of the lambda expression.
Tested using Spoofax 0.5.2.93 and its included Stratego.
Submitted by Thomas Schaap on 17 August 2010 at 15:34
Issue Log
This is by design. All the “variables” at the left-hand side of the rule will be scoped, the rest will not. To fix this, scope explicitly:
someRulename : x -> <map({aa, bb: \Plus(a,b) -> Plus(a,b) with aa := a; bb := b})> [Plus(Num(1),Num(2)),Plus(Num(3),Num(4))]
Log in to post comments