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

minus sign in #set requires spaces to surround it

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 2.0
    • Component/s: Engine
    • Labels:
      None

      Description

      The following example:

      #set($thisCampNumber = 10)
      #set($nextCampNumber = $thisCampNumber+1)
      #set($previousCampNumber = $thisCampNumber-1)
      #set($previousCampNumberB = $thisCampNumber - 1)

      1: $thisCampNumber<br>
      2: $nextCampNumber<br>
      3: $previousCampNumber<br>
      4: $previousCampNumberB<br>

      produces this result

      1: 10
      2: 11
      3: $previousCampNumber
      4: 9

      Note that using a minus sign in a #set statement does not work if there are no spaces around it. (however, the same is not true for +).

        Activity

        Hide
        nbubna Nathan Bubna added a comment -

        This is because '-' is a valid character in a reference.

        Try doing #set( $thisCampNumber-1 = "hello world" ) before running your test.

        Show
        nbubna Nathan Bubna added a comment - This is because '-' is a valid character in a reference. Try doing #set( $thisCampNumber-1 = "hello world" ) before running your test.
        Hide
        wglass Will Glass-Husain added a comment -

        ok, guess I'm satisfied with Nathan's explanation.

        Show
        wglass Will Glass-Husain added a comment - ok, guess I'm satisfied with Nathan's explanation.
        Hide
        nbubna Nathan Bubna added a comment -

        I should note that i didn't suggest any course of action, because i'm ambivalent about the state of this. This is a "feature" that i believe few know about or use. While i don't think we should change it in the 1.x series, i wouldn't oppose dropping '-' from the set of valid reference characters in 2.0. Of course, I wouldn't champion that either, so i won't re-open and assign this to that version myself.

        Show
        nbubna Nathan Bubna added a comment - I should note that i didn't suggest any course of action, because i'm ambivalent about the state of this. This is a "feature" that i believe few know about or use. While i don't think we should change it in the 1.x series, i wouldn't oppose dropping '-' from the set of valid reference characters in 2.0. Of course, I wouldn't champion that either, so i won't re-open and assign this to that version myself.
        Hide
        claude Claude Brisson added a comment -

        Pertinent for 2.x

        Show
        claude Claude Brisson added a comment - Pertinent for 2.x
        Hide
        claude Claude Brisson added a comment -

        fixed by commit 1742952

        Show
        claude Claude Brisson added a comment - fixed by commit 1742952

          People

          • Assignee:
            claude Claude Brisson
            Reporter:
            wglass Will Glass-Husain
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development