Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[new-parser] Broken named consequences inside OR #5945

Closed
yurloc opened this issue May 14, 2024 · 2 comments
Closed

[new-parser] Broken named consequences inside OR #5945

yurloc opened this issue May 14, 2024 · 2 comments
Assignees

Comments

@yurloc
Copy link
Contributor

yurloc commented May 14, 2024

Parent issue

Failing tests

  • org.drools.mvel.integrationtests.EdgeCaseNonExecModelTest#testNamedConsequencesInsideOR1
  • org.drools.mvel.integrationtests.EdgeCaseNonExecModelTest#testNamedConsequencesInsideOR2
  • Probably also org.drools.mvel.compiler.beliefsystem.abductive.AbductionTest#testAbductiveLogicSprinklerAndRainExample because the rule contains named consequences connected with OR.

Notes

The new parser creates a slightly more flat descr structure compared to the old parser. I think that's the cause of the later compilation error.

Old parser output (expected)

lhs : [AND [[OR [[AND [[Pattern: id=$a; objectType=Cheese], do[t1]] ], [Pattern: id=$b; objectType=Cheese]] ], [Pattern: id=$c; objectType=Cheese]] ]
- 0 :       [OR [[AND [[Pattern: id=$a; objectType=Cheese], do[t1]] ], [Pattern: id=$b; objectType=Cheese]] ]
- 1 :                                                                                                          [Pattern: id=$c; objectType=Cheese]

Note that the first pattern $a : Cheese() and its consequence t1 are AND-connected ($a AND t1) OR $b.

New parser output (actual)

lhs : [AND [[OR [[Pattern: id=$a; objectType=Cheese], do[t1], [Pattern: id=$b; objectType=Cheese]] ], [Pattern: id=$c; objectType=Cheese]] ]
- 0 :       [OR [[Pattern: id=$a; objectType=Cheese], do[t1], [Pattern: id=$b; objectType=Cheese]] ]
- 1 :                                                                                                 [Pattern: id=$c; objectType=Cheese]

Flat OR structure connecting three elements ($a OR t1 OR $b).

Rule code snippet

rule R1 when
    ( $a: Cheese ( type == "stilton" ) do[t1] or $b: Cheese ( type == "gorgonzola" ) )
    $c: Cheese ( type == "cheddar" )
then
    results.add( $c.getType() );
then[t1]
    results.add( $a.getType() );
end

Error output

### parse : ANTLR4_PARSER_ENABLED = true
12:48:17.268 [main] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:KieBaseModelName
Rule Compilation error : [Rule name='R1']
	$a cannot be resolved


12:48:17.269 [main] ERROR o.d.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem:165 - KieBuilder errors: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=4, column=0
   text=Rule Compilation error $a cannot be resolved]]

java.lang.AssertionError: [[Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=4, column=0
   text=Rule Compilation error $a cannot be resolved]]] 
Expecting empty but was: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=4, column=0
   text=Rule Compilation error $a cannot be resolved]]

	at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:169)
	at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:134)
	at org.drools.testcoverage.common.util.KieUtil.buildAndInstallKieModuleIntoRepo(KieUtil.java:78)
	at org.drools.testcoverage.common.util.KieUtil.buildAndInstallKieModuleIntoRepo(KieUtil.java:72)
	at org.drools.testcoverage.common.util.KieUtil.getKieModuleFromResources(KieUtil.java:249)
	at org.drools.testcoverage.common.util.KieUtil.getKieModuleFromResources(KieUtil.java:238)
	at org.drools.testcoverage.common.util.KieBaseUtil.getKieBaseFromKieModuleFromResources(KieBaseUtil.java:102)
	at org.drools.testcoverage.common.util.KieBaseUtil.getKieBaseFromKieModuleFromDrl(KieBaseUtil.java:115)
	at org.drools.mvel.integrationtests.EdgeCaseNonExecModelTest.executeTestWithDRL(EdgeCaseNonExecModelTest.java:105)
	at org.drools.mvel.integrationtests.EdgeCaseNonExecModelTest.testNamedConsequencesInsideOR1(EdgeCaseNonExecModelTest.java:73)
@tkobayas
Copy link
Contributor

/take

@tkobayas
Copy link
Contributor

Fixed by #5950

@github-project-automation github-project-automation bot moved this from 📋 Backlog to 🎯 Done in 🦉 KIE Podling Board May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🎯 Done
Development

No branches or pull requests

2 participants