TypeCobol
TypeCobol copied to clipboard
Invalid precedence of operators when building abbreviated relation conditions
Describe the bug Following #2083, it appears that the syntax is correctly supported but the semantics of abbreviated expressions is wrong. See the code example.
To Reproduce
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC X.
01 B PIC X.
01 C PIC X.
01 D PIC X.
01 E PIC X.
PROCEDURE DIVISION.
IF (A = B OR C AND D = E)
DISPLAY "with abbreviated syntax"
END-IF
IF (A = B OR (A = C AND D = E))
DISPLAY "with explicit parentheses"
END-IF
IF (A = B OR A = C AND D = E)
DISPLAY "with implicit operator precedence rules"
END-IF
GOBACK
.
END PROGRAM TCOMFL06.
Expected behavior The 3 conditions are identical. While the parser gives a correct result for the last two, the first is incorrect:
{A B EqualTo A C EqualTo OR D E EqualTo AND} --> KO
{A B EqualTo A C EqualTo D E EqualTo AND OR} --> OK
{A B EqualTo A C EqualTo D E EqualTo AND OR} --> OK
Technical TODO
How to test automatically TODO Check if we already have tests on conditions