Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344424 - Wrong result from recursive call
Summary: Wrong result from recursive call
Status: CLOSED FIXED
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-02 05:31 EDT by Hallvard Traetteberg CLA
Modified: 2016-04-05 03:15 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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