Incompatible argument type in a method

CachéQuality release 
1.3.0
Id 
OS0078
Rule type 
Severity 

Minor

Minor
SQALE characteristic 
  • Reliability
    • Instruction
Tags 
runtime-failure
Remediation function 
Constant/issue
Remediation cost 
1h

The class must exists.

Noncompliant Code Example

In following code, methods DoWork2 and DoWork3 expects to receive %String as argument, but receive Sample.Person and will raise a "PARAMETER error" message on runtime.

Class Sample.NightWatch
{
    ClassMethod DoWork1(pObj As Sample.Person)
    {
        Write !,pObj.name_" "_pObj.surname
    }

    ClassMethod DoWork2(pObj As Sample.Person, pNmbObj As %Numeric)
    {
        For i=1:1:pNmbObj
        {
            Write !,pObj.name_" "_pObj.surname
        }
    }

    ClassMethod DoWork3(pstrObj As %String)
    {
        Write !,pstrObj
    }

    ClassMethod foo()
    {
        #Dim objPerson As Sample.Person = ##class(Sample.Person).%New()
        Set objPerson.name = "Jon"
        Set objPerson.surname = "Snow"
        Set objPerson.age = 42

        Do ..DoWork1(objPerson)
        Do ..DoWork2("Ygritte", 3)  // PARAMETER error
        Do ..DoWork3(objPerson)     // PARAMETER error
    }
}