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 and its included Stratego.

Submitted by Thomas Schaap on 17 August 2010 at 15:34

On 17 August 2010 at 18:34 Zef Hemel commented:

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))]

On 20 December 2011 at 16:00 Lennart Kats closed this issue.

Log in to post comments