TypeCobol icon indicating copy to clipboard operation
TypeCobol copied to clipboard

Missing compatibility check between Picture and Usage

Open efr15 opened this issue 1 year ago • 0 comments

Describe the bug Here are some missing compatibility checks between Picture and Usage:

  • A picture corresponding to the NationalEdited category cannot be declared with DISPLAY1 usage.
  • A DBCS picture must be declared explicitly with DISPLAY1 usage.

Maybe other ones are missing (IBM specifications should checked).

To Reproduce Cobol code that cause the bug:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PGM-COMP.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      
        01 group1.
      *   The "PICTURE" clause for item "VAR-N" was not compatible with the specified "USAGE". "USAGE DISPLAY" was assumed.
           05 var-n PIC B/0N USAGE IS DISPLAY-1.
      *   "USAGE DISPLAY-1" was not specified for DBCS item "VAR-G". "USAGE DISPLAY-1" was assumed.
           05 var-g PIC B(2)G(2).
      
       PROCEDURE DIVISION.
           GOBACK
           .      
      
       END PROGRAM PGM-COMP.

Expected behavior Diagnostics should be created for each var-x declaration.

Technical Where those checks should be implemented PictureValidator ? Or Existing code in CrossChecker ? See https://github.com/TypeCobolTeam/TypeCobol/blob/00531317df61053ea383434e65a7408b3d1e6db6/TypeCobol/Compiler/Diagnostics/CrossChecker.cs#L848

How to test automatically Standard tests with the given source code.

efr15 avatar Feb 05 '24 11:02 efr15