Doubling strategies
In some cases, a strategy contains its body twice in the generated Java code.
Might have to do with circular imports. Tested with strc-java-0.17.9pre20768.
File1:
module x imports libstratego-lib application-ini strategies main = try(strat); bagof-Test strat: x -> x where rules(Test :+= "x"); fail
File2:
module y imports x
Program should print [“x”] but prints [“x”,“x”] due to the double body of strat in the generated java code.
Submitted by Nathan Bruning on 25 April 2010 at 12:39
Issue Log
That’s not good. This actually sounds like it would be a problem in the Stratego front-end though. Do you know if it also occurs in the C version? As for your example, I suppose module x would import module y?
Yes, confirmed with strc-0.18pre20635 too.
This is a bug in pack-stratego. I have fixed it in r.20800, but actually pack-stratego should still be rewritten using dynamic rules in stead.
@nathan: I think this fix is now integrated into the latest Spoofax plugin, but you’d have to test it to be sure.
This is fixed for circular imports.
However, having two imports of the same file using a different path still triggers the bug. For example:
module mod1 imports common module mod2 imports ../common
(where in both cases common refers to the same common.str file)
I hate your example but you make a good point. Some applications use imports relative to multiple different import paths. I’ve never seen
../
though :o
Using strc-java revision 20888, a ‘doubled’ strategy appeared once more. The two parts were not exactly equal though; only the first one had a call inlined but not the second one. Probably the reason why the fix of 20800 didn’t work for this case…
Log in to post comments