Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-285

reference within macro and foreach is incorrect

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.4
    • 1.5
    • Engine
    • None
    • Operating System: other
      Platform: Other
    • 30343

    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.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            henning Henning Schmiedehausen
            gilles.scokart@be.fujitsu.com Gilles Scokart
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment