metaborg / stratego

Apache License 2.0
10 stars 6 forks source link

Overlapping provider tasks for resource error during build #26

Closed ivardb closed 5 months ago

ivardb commented 2 years ago

Describe the bug During the build the following error occurs:

Errors occurred during the build.
Errors running builder 'Spoofax LWB builder' on project 'chocopy.backend'.
Overlapping provider tasks for resource. Cause:
resource
  eclipse-resource##/chocopy.backend/build/generated/sources/languageSpecification/java/mb/chocopy/strategies/aux_$Locations_0_2.java
was provided by task
  #stratego.Back(BackInput.DynamicRule(eclipse-resource##/chocopy.backend/build/generated/sources/languageSpecification/java/mb/chocopy/strategies, ("LocalVarOffset",0,0)))
and task
  #stratego.Back(BackInput.DynamicRule(eclipse-resource##/chocopy.backend/build/generated/sources/languageSpecification/java/mb/chocopy/strategies, ("Load",0,0)))

However no errors in the files occur outside of generated files

Project Stratego 2 project

Versions Spoofax: 0.16.15

To Reproduce With bug: https://gitlab.ewi.tudelft.nl/CS4200/2021-2022/student-icdebruin/-/commit/0c90bf5cde91b5fceab1ae64040829400be92171

Fixed: (Change from strategies to rules is not necessary) https://gitlab.ewi.tudelft.nl/CS4200/2021-2022/student-icdebruin/-/commit/06cbad8c7dad644e94986e5ba3d287933ac91044

Observed behaviour Two bugs have been found:

Expected behaviour Either a good error in the file itself or better no error as having Class anywhere in a name cause a problem seem not intended

Additional context No changes to the dynamic rules mentioned in the actual error were made to fix the problem

ivardb commented 2 years ago

@Apanatshka I have gotten a similar error to this one on multiple other names by now as well such as InitialValues, Attributes and a few more. It might be related to how many dynamic rules are being used as I am getting this error on more and more names while not having this problem earlier in the project at all

ivardb commented 2 years ago

The bug persists in 0.16.17 once all type errors are fixed as can be seen in this commit. Occasionaly the error does not occur. If this happens just rename one of the dynamic rules in explicate-control and it will most likely occur again: https://gitlab.ewi.tudelft.nl/CS4200/2021-2022/student-icdebruin/-/commit/442fc8b9a6d7a32b0ec2fd416ef5ef8abc701de6

Apanatshka commented 2 years ago

I can reproduce this issue with that last commit you linked to. I'm working on it.

Apanatshka commented 2 years ago

@ivardb there might not be another release of Spoofax 3 before the end of the course, so you might not be able to use the fix I just developed for this issue. Now that I know what the problem is, I can give you a workaround though. Only define a single dynamic rule per strategy. So if you have multiple dynamic rule definitions in a single strategy (or spread over multiple definitions of a single strategy), split it up with a helper:

strategies

// triggers the bug:
foo: a -> a
  with rules(LocalVarOffset: () -> a)
  with rules(Load: () -> a)

// doesn't trigger the bug:
bar: a -> a
  with rules(LocalVarOffset: () -> a)
  with bar-helper(|a)

bar-helper(|a) = rules(Load: () -> a)