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

Bug 356585

Summary: Init section of "for" blocks should be done at each iteration
Product: [Modeling] Acceleo Reporter: Laurent Delaigue <laurent.delaigue>
Component: CoreAssignee: Project Inbox <acceleo-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: laurent.goubet
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Laurent Delaigue CLA 2011-09-02 09:05:24 EDT
Build Identifier: 

Currently in Acceleo, the initialization of variables declared in the init section of a "for" block is done once.
It would make much more sense to perform the init block once for each iteration of the block (where the iterator variable could be used).
And also, not to do this initialization at all if there is no iteration to be made! (iterating over an empty list I mean)

Reproducible: Always

Steps to Reproduce:
[for (s : String | Sequence{}) { len : Integer = s.size();}]
[len/]
[/for]
Comment 1 Laurent Goubet CLA 2016-04-04 08:38:15 EDT
init sections contain the definition of a set of variables that are meant to be used in the body of their owning block. For this purpose they are evaluated _before_ the block itself, and cannot use variables defined in said block (the "s" variable in your example). We do not plan on changing this behavior as the specification doesn't make it clear.