Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331118 - Inappropriate behavior when calling query with a parameter name equals to template caller paramater name
Summary: Inappropriate behavior when calling query with a parameter name equals to tem...
Status: CLOSED WONTFIX
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: PC Linux
: P3 major
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-25 07:51 EST by Mikaël Barbero CLA
Modified: 2016-03-30 08:41 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikaël Barbero CLA 2010-11-25 07:51:57 EST
Hi guys,

Here is a sample module to reproduce the behavior:

[comment encoding = UTF-8 /]
[module test('http://www.eclipse.org/emf/2002/Ecore')/]

[template public test(e : EPackage)]
	[comment @main /]
	[file (e.name + '.txt', false, 'UTF-8')]
		[for (it : EClass | e.eClassifiers->filter(EClass))]
	q1: [it.q1(e)/]
	q2: [it.q2(e)/]
		[/for]
	[/file]
[/template]

[query public q1(e : EClass, ep : EPackage) : String =  
	ep.name + '.' + e.name
/]

[query public q2(ec : EClass, pa : EPackage) : String =  
	pa.name + '.' + ec.name
/]

Despite q1 and q2 should do the same thing, the output is (with Ecore.ecore as input model) :

	q1: EAttribute.EAttribute
	q2: ecore.EAttribute
	q1: EAnnotation.EAnnotation
	q2: ecore.EAnnotation
	q1: EClass.EClass
	q2: ecore.EClass
	q1: EClassifier.EClassifier
	q2: ecore.EClassifier
	q1: EDataType.EDataType
	q2: ecore.EDataType
        [....]

Strange, isn't it?

Mikael
Comment 1 Laurent Goubet CLA 2011-01-25 07:19:11 EST
This is only reproducible in this very particular case of a query with two parameters, the first _parameter_ being named the same as the second _argument_ passed to the call.

[test(x, c)/] <- this c

[query public test(c : T, y : U)/] <- and this one

When Acceleo evaluates the value of the parameter c, "c = x", it replaces the value of the variable named "c". Then, when it evaluates the value of the parameter y, "y = c", it will use the new value of "c" instead of the old one.

This cannot be reproduced in any other configuration (even with identical templates) than this.
Comment 2 Laurent Goubet CLA 2016-03-30 08:41:14 EDT
Only ever raised once and too specific to adress.