eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[cg] Wrong CG for a Variable init expression with a safe navigation #1761

Closed eclipse-ocl-bot closed 2 hours ago

eclipse-ocl-bot commented 2 hours ago

| --- | --- | | Bugzilla Link | 507619 | | Status | RESOLVED FIXED | | Importance | P3 normal | | Reported | Nov 16, 2016 10:14 EDT | | Modified | Nov 18, 2016 09:23 EDT | | Depends on | 507658 | | Blocks | 507628 | | Reporter | Adolfo Sanchez-Barbudo Herrera |

Description

When working on some OCL declarations, I've found a problem in the code generator, because the produced code is not the expected one

Full repro coming as soon as I get bugzilla ID.

eclipse-ocl-bot commented 2 hours ago

By Adolfo Sanchez-Barbudo Herrera on Nov 16, 2016 10:22

Repro:

The ocl-code of the method (in the java-doc) has a suspicious:

let parent : Visitable[1] = oclContainer()?.oclAsType(Visitable)\ in ...

Since the init expression is a safe navigation expression, the variable should be nullable ([?])

[1] org.xtext.example.delphi.build\src\org\xtext\example\companies\build\mwe\GenerateCS2ASTx.mwe2\ [2] org.xtext.example.delphi\src-gen\org\xtext\example\delphi_Delphi_qvtp_qvtcas\Delphi_qvtp_qvtcas.java

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Nov 16, 2016 11:21

You'll find that most of the problems can be seen in Delphi.qvtias, or in this case DelphiLookup.ocl. The CG falls into the category where problems are fairly catastrophic so there aren't that many in supported functionality.

Hovering over parent in "let parent = " in DelphiLookup.ocl shows a Visitable[1] so the problem is in the OCL LetExp CS2AS.

Unfortunately changing to "let parent : Variable[?] = " makes no difference so the bug must be an incorrect analysis of "oclContainer()?.oclAsType(Visitable)" as [1].

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Nov 16, 2016 13:13

There is a missing isRequired assignment in EssentialOCLCSLeft2RightVisitor.doVisitNavigationOperatorCS, but it is not obvious how to test it.

A few more WFRs in Pivot.ocl and this would have been diagnosed, and can then be tested.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Nov 17, 2016 05:10

(In reply to Ed Willink from comment #3)

There is a missing isRequired assignment in EssentialOCLCSLeft2RightVisitor.doVisitNavigationOperatorCS

Pushed to ewillink/507619

but it is not obvious how to test it.

Waiting for Bug 507658

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Nov 18, 2016 09:23

(In reply to Ed Willink from comment #4)

Waiting for Bug 507658

A JUnit test now uses the LetVariable::CompatibleNullityForInitializer to diagnose the origianl CS2AS deficiency.

Pushed to master for M4.