Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-14454

CHOOSE(0) constant-folded incorrectly

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 6.0.0, 5.6.0
    • Code Generator
    • None

    Description

      For the following code...

      toText(UNSIGNED1 i) := CHOOSE(i,'one','two','elsevalue');
      OUTPUT(toText(0));
      OUTPUT(toText(1));
      OUTPUT(toText(2));
      OUTPUT(toText(3));
      OUTPUT(toText(4));

      The values 1 and 2 yield their counterparts, and the values 3 and 4 yield 'elsevalue' as expected. However, passing 0 yields 0.

      Shouldn't passing 0 yield 'elsevalue'?

      I do see I'm violating the expected type of input, as the first parameter is described in the user's guide as "An arithmetic expression that results in a positive integer and determines which value parameter to return". However, given the elsevalue is broadly described as "The value to return when the expression returns an out-of-range value", it seems more logical to return it rather than lapse into undefined behavior.

      Attachments

        Issue Links

          Activity

            People

              ghalliday Gavin Halliday
              leonarta Todd Leonard
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: