Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344424

Summary: Wrong result from recursive call
Product: [Modeling] Acceleo Reporter: Hallvard Traetteberg <hal>
Component: CoreAssignee: Project Inbox <acceleo-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: laurent.goubet
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
See Also: https://git.eclipse.org/r/69724
https://git.eclipse.org/c/acceleo/org.eclipse.acceleo.git/commit/?id=3b21655074aed2c171df0e5273421d140d1120b2
Whiteboard:

Description Hallvard Traetteberg CLA 2011-05-02 05:31:20 EDT
I wanted to traverses up a chain of Package objects, to compute the full name, and tried the following:

[query public packageFullName(pack : Package, suffix : String) : String =
    if pack.oclIsUndefined() then suffix else packageFullName(pack._package, pack.name + '.' + suffix) endif
/]

If called on a chain of packages with names org.eclipse.tests it returns <undefined-object>.org.eclipse where <undefined-object> is the result of calling oclUndefined.toString(). It is as if the pack.name expression in pack.name + '.' + suffix is interpreted as pack._package.name.

However, the following works:

[query public packageFullName(pack : Package, suffix : String) : String =
    if pack.oclIsUndefined() then suffix else let suffix : String = pack.name + '.' + suffix in packageFullName(pack._package, suffix) endif
/]

I.e. the argument is computed before the recursive call to packageFullName. I cannot understand why the result should differ and be wrong in the first case.
Comment 1 Eclipse Genie CLA 2016-04-01 10:37:32 EDT
New Gerrit change created: https://git.eclipse.org/r/69724