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

UNSIGNED gets implicitly cast to BOOLEAN in spite of documentation to the contrary

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.0.x
    • Fix Version/s: 7.8.0
    • Component/s: Code Generator
    • Labels:

      Description

      Reading the language reference, I’m not sure if an implicit cast of an UNSIGNED to a BOOLEAN is expected or not (not sure what the highlighted section below was meaning to convey):

       During expression evaluation, different value types may be implicitly cast in order to properly evaluate the expression. Implicit casting always means promoting one value type to another: INTEGER to STRING or INTEGER to REAL. BOOLEAN types may not be involved in mixed mode expressions.

       __  

      I was looking at an issue recently, and the code effectively was written like this (simplified example):

           Somefunc(STRING str, BOOLEAN isConfirmed = FALSE, UNSIGNED seq = 1) := FUNCTION

                   s := str + seq;

                   c := IF(isConfirmed, 'CONFIRMED: ', 'NOT CONFIRMED: ');

                   RETURN c + s;                   

            END;

       The calling code was not correctly aligned with the function parameters:

            Foo := Somefunc(‘bar’, 8);

       This produced no warning, but didn’t function the way the developer intended. 

       

      If there is concern that changing this behavior would break a lot of existing code, it would at least be beneficial for this to generate a warning.

       

      Gavin Halliday 

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ghalliday Gavin Halliday
                Reporter:
                kev77log Kevin Logemann
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: