DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4209>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4209

Assigning null value to variable appears to be a no-op

           Summary: Assigning null value to variable appears to be a no-op
           Product: Velocity
           Version: 1.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Source
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I created an array with alternating null and non-null values:

        context.put("test", new String[] { null, "a", null, "b", null });

In the vm file, I have this code:

    #foreach ($x in $test)
    element: $x
    #if ($x)conditional: $x
    #end

Here is the output:

    element: $x
    element: a
    conditional: a
    element: a
    conditional: a
    element: b
    conditional: b
    element: b
    conditional: b

I believe the correct output would be:

    element: $x
    element: a
    conditional: a
    element: $x
    element: b
    conditional: b
    element: $x

In other words, once a variable has a non-null value, it looks as if
the assignment of a null value is handled incorrectly, leaving the
value of the variable unchanged.

Jack Orenstein

Reply via email to