ascot diagnostics

A8892

Error: Variable ‘{name}’ is {ty1} in one branch but {ty2} in another

Two branches meet here, and each leaves the variable declared by #Dim as a different type. From here on it has no single declared type. IRIS compiles and runs the code, since a #Dim type has no effect at run time. Declare the variable once, before the branches, with a type that fits both values.

IRIS compiles the example.

Class Demo.InconsistentDeclaration
{

ClassMethod Describe(asNumber As %Boolean) As %String
{
    If asNumber { //! A8892
        #Dim value As %Integer
        Set value = 42
    } Else {
        #Dim value As %String
        Set value = "forty-two"
    }
    Quit value
}

}

All diagnostics