Incompatible argument type in a method
objectscriptQuality release
Id
OS0078
Rule type
Bug
Severity
Minor
Minor
SQALE characteristic
- Reliability
- Instruction
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
}
}
Parameters
| Name | Description | Default value |
|---|---|---|
ignoreUndetermined
| Ignore 'Unable to determine type' error as ObjectScript will consider the parameter being passed as %String
| false
|

