Variable not found

CachéQuality release 
1.3.0
Id 
OS0079
Rule type 
Severity 

Critical

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

A variable is used in a expression, but was neither passed as argument nor set before.

Declare or define as argument the variable you need to use, or remove the reference to the undefined variable.

Noncompliant Code Example

Following code will compile, but on runtime the Add method will fail with "UNDEFINED error" message.

Method Add()
{
    Set a=1
    Set c=a+b // b is UNDEFINED
    Write !,c
}

Compliant Solution

Method Add(b AS %Numeric)
{
    Set a=1
    Set c=a+b
    Write !,c
}

Exceptions

Methods with ProcedureBlock=0 are not checked because those methods can use variables from global scope.