Issue Details (XML | Word | Printable)

Key: VELOCITY-285
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Henning Schmiedehausen
Reporter: Gilles Scokart
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Velocity

reference within macro and foreach is incorrect

Created: 27/Jul/04 05:24 PM   Updated: 15/Oct/08 01:19 AM
Return to search
Component/s: Engine
Affects Version/s: 1.4
Fix Version/s: 1.5

Time Tracking:
Not Specified

Environment:
Operating System: other
Platform: Other
Issue Links:
Blocker
 
Reference
 

Bugzilla Id: 30343
Resolution Date: 06/Nov/06 10:41 PM


 Description  « Hide
It seems that there is a bug when we have loop into a recursive macro.

Here is the test I run :

#macro (test_loop $p)
call to test_loop ($p)
#foreach($child in $p)
    in the loop the param should not be changed : ($p)
#test_loop($child)
#end
return
#end

#set($l1=["a"])
#set($l = [$l1])
#test_loop($l)


It produce:

call to test_loop ([[a]])
in the loop the param should not be changed : ([[a]])
call to test_loop ([a])
in the loop the param should not be changed : (a)
call to test_loop (a)
return
return
return

IMHO, it should be
call to test_loop ([[a]])
in the loop the param should not be changed : ([[a]])
call to test_loop ([a])
in the loop the param should not be changed : ([a])
call to test_loop (a)
return
return
return

The difference is in the second recusive call. I don't know why, but it seems
that the instruction #foreach($child in $p) has modified $p that contains the
value of $child.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jeff Turner made changes - 13/Sep/05 12:50 PM
Field Original Value New Value
issue.field.bugzillaimportkey 30343 12315155
Will Glass-Husain made changes - 19/Sep/05 07:53 AM
Description It seems that there is a bug when we have loop into a recursive macro.

Here is the test I run :

#macro (test_loop $p)
call to test_loop ($p)
#foreach($child in $p)
    in the loop the param should not be changed : ($p)
#test_loop($child)
#end
return
#end

#set($l1=["a"])
#set($l = [$l1])
#test_loop($l)


It produce:

call to test_loop ([[a]])
in the loop the param should not be changed : ([[a]])
call to test_loop ([a])
in the loop the param should not be changed : (a)
call to test_loop (a)
return
return
return

IMHO, it should be
call to test_loop ([[a]])
in the loop the param should not be changed : ([[a]])
call to test_loop ([a])
in the loop the param should not be changed : ([a])
call to test_loop (a)
return
return
return

The difference is in the second recusive call. I don't know why, but it seems
that the instruction #foreach($child in $p) has modified $p that contains the
value of $child.
It seems that there is a bug when we have loop into a recursive macro.

Here is the test I run :

#macro (test_loop $p)
call to test_loop ($p)
#foreach($child in $p)
    in the loop the param should not be changed : ($p)
#test_loop($child)
#end
return
#end

#set($l1=["a"])
#set($l = [$l1])
#test_loop($l)


It produce:

call to test_loop ([[a]])
in the loop the param should not be changed : ([[a]])
call to test_loop ([a])
in the loop the param should not be changed : (a)
call to test_loop (a)
return
return
return

IMHO, it should be
call to test_loop ([[a]])
in the loop the param should not be changed : ([[a]])
call to test_loop ([a])
in the loop the param should not be changed : ([a])
call to test_loop (a)
return
return
return

The difference is in the second recusive call. I don't know why, but it seems
that the instruction #foreach($child in $p) has modified $p that contains the
value of $child.
Environment Operating System: other
Platform: Other
Operating System: other
Platform: Other
Priority Major [ 3 ] Minor [ 4 ]
Fix Version/s 1.5 [ 12310253 ]
Bugzilla Id 30343
Assignee Velocity-Dev List [ velocity-dev@jakarta.apache.org ]
Summary recursion and loop reference within macro and foreach is incorrect
Henning Schmiedehausen made changes - 05/Nov/06 06:55 PM
Component/s Source [ 12310214 ]
Bugzilla Id 30343
Component/s Engine [ 12311337 ]
Henning Schmiedehausen made changes - 06/Nov/06 09:30 PM
Assignee Henning Schmiedehausen [ henning ]
Henning Schmiedehausen made changes - 06/Nov/06 09:30 PM
Status Open [ 1 ] In Progress [ 3 ]
Henning Schmiedehausen made changes - 06/Nov/06 10:41 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Henning Schmiedehausen made changes - 08/Mar/07 12:04 AM
Status Resolved [ 5 ] Closed [ 6 ]
Will Glass-Husain made changes - 25/Mar/07 12:26 AM
Link This issue relates to VELOCITY-532 [ VELOCITY-532 ]
Byron Foster made changes - 15/Oct/08 01:19 AM
Link This issue is blocked by VELOCITY-630 [ VELOCITY-630 ]