Property not found

objectscriptQuality release 
1.3.0
Id 
OS0081
Rule type 
Bug
Severity 

Critical

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

Declare the property you need to use in the class, or remove the reference to the undefined property.

Noncompliant Code Example

Following code will compile, but on runtime the Set obj.test will fail with "PROPERTY DOES NOT EXIST error" message.

Class Sample.NightWatch Extends %RegisteredObject
{
    Property name As %String;
    Property surname As %String;

    Method CreateJon()
    {
        Set obj = ##class(Sample.Person).%New()
        Set obj.name = "Jon"
        Set obj.surname = "Snow"
        Set obj.age = 27 // age is UNDEFINED

        Return obj
    }
}

Compliant Solution

Class Sample.NightWatch Extends %RegisteredObject
{
    Property name As %String;
    Property surname As %String;
    Property age As %Integer;

    Method CreateJon()
    {
        Set obj = ##class(Sample.Person).%New()
        Set obj.name = "Jon"
        Set obj.surname = "Snow"
        Set obj.age = 27

        Return obj
    }
}