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

On 26 April 2010 at 11:23 Lennart Kats commented:

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?


On 27 April 2010 at 13:05 Nathan Bruning commented:

Yes, confirmed with strc-0.18pre20635 too.


On 28 April 2010 at 13:21 Rob Vermaas commented:

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.


On 3 May 2010 at 12:13 Lennart Kats commented:

@nathan: I think this fix is now integrated into the latest Spoofax plugin, but you’d have to test it to be sure.


On 4 May 2010 at 13:51 Nathan Bruning commented:

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)


On 4 May 2010 at 14:20 Lennart Kats commented:

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


On 30 May 2010 at 15:58 Nathan Bruning commented:

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…


On 28 January 2013 at 14:47 Eelco Visser removed tag 0.18

On 28 January 2013 at 14:47 Eelco Visser tagged interesting

Log in to post comments