Open fm-117 opened 3 years ago
This is related to the nature of functions. Cobol defines 4 types of intrinsic functions based on their return type:
And there are restrictions on how/where each types of functions can be used:
COMPUTE var1 = FUNCTION LOWER-CASE('A')
is invalid)MOVE FUNCTION LENGTH('hello')
above).While most functions have a pre-determined return type, some (MIN
and MAX
) are overloaded and actual return type depends on argument types. Therefore, the separation between text functions and number functions can't be done during syntax check and has to be done during semantic check.
To help find whether a function is used inside or outside of an arithmetic expression, the visitor must be improved. Adding BeginExpression
and EndExpression
methods (based on what is done for CodeElement) would allow to track expression context.
The overload resolution mechanism would have to integrate into existing code, see inheritors of FunctionCall
and BuildProfile
methods.
Describe the bug Some intrinsic functions are not allowed in a MOVE statement, our parser allows it but IBM compiler doesn't.
To Reproduce (Type)Cobol code that cause the bug : (if any)
Expected behavior Our parser should create a diagnostic on
MOVE FUNCTION LENGTH('hello')
according to the IBM compiler behavior.TODO: