Project

General

Profile

Bug #10237

keepTildes is keeping tilde when preprocessor directive contains tilde and curly brace

Added by Stefan Vieru about 1 year ago. Updated 16 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
4GL Preprocessor

Related issues

Related to Conversion Tools - Bug #6308: post string literal alternative coding quirk in 4GL preprocessor Internal Test
Related to Testing - Support #6859: preprocessor tests Test
Related to Conversion Tools - Bug #11835: -keeptildes keeps escape text for macro-expanded content, where OE emits only the byte Review

History

#1 Updated by Stefan Vieru about 1 year ago

Having the following testcase:

DEFINE VARIABLE iSDOLoop            AS INTEGER    NO-UNDO.
DEFINE VARIABLE cSDOList            AS CHARACTER  NO-UNDO.
DEFINE VARIABLE hSDOHandle          AS HANDLE     NO-UNDO.
DEFINE VARIABLE lStatic             AS LOGICAL    NO-UNDO.

cSDOList = "7896".
lStatic = true.

&SCOPED-DEFINE NumTTS 5

&SCOPED-DEFINE fetchTT &IF {&NumTTs} < ~{&num~} &THEN~
 WHEN ~{&num~} THEN message {&NumTTs} ~{&num~}.~
 &ENDIF

DO iSDOLoop = 1 TO NUM-ENTRIES(cSDOList):
  hSDOHandle = WIDGET-HANDLE(ENTRY(iSDOLoop,cSDOList)).
  IF lStatic THEN
  DO:
   CASE iSDOLoop:
      &SCOPED-DEFINE num 1
      {&fetchTT} 
      &SCOPED-DEFINE num 2
      {&fetchTT} 
      &SCOPED-DEFINE num 3
      {&fetchTT} 
      &SCOPED-DEFINE num 4
      {&fetchTT} 
      &SCOPED-DEFINE num 5
      {&fetchTT} 
      &SCOPED-DEFINE num 6
      {&fetchTT} 
      &SCOPED-DEFINE num 7
      {&fetchTT} 
      &SCOPED-DEFINE num 8
      {&fetchTT} 
   END CASE.
  END.
END.

When we preprocess in OE we should get:

DEFINE VARIABLE i               AS INTEGER    NO-UNDO.
DEFINE VARIABLE list            AS CHARACTER  NO-UNDO.

list = "3456789".

DO i = 1 TO NUM-ENTRIES(list):
   CASE i:
            -
            -
            -
            -
            -
            WHEN 6 THEN message "5 < 6". 
            WHEN 7 THEN message "5 < 7". 
            WHEN 8 THEN message "5 < 8". 
   END CASE.
END.

Ignore the -, I've inserted them to keep the empty lines

When we preprocess in FWD without keepTildes we get the same output, but when enabling it we get:

DEFINE VARIABLE iSDOLoop            AS INTEGER    NO-UNDO.
DEFINE VARIABLE cSDOList            AS CHARACTER  NO-UNDO.
DEFINE VARIABLE hSDOHandle          AS HANDLE     NO-UNDO.
DEFINE VARIABLE lStatic             AS LOGICAL    NO-UNDO.

cSDOList = "7896".
lStatic = true.

DO iSDOLoop = 1 TO NUM-ENTRIES(cSDOList):
  hSDOHandle = WIDGET-HANDLE(ENTRY(iSDOLoop,cSDOList)).
  IF lStatic THEN
  DO:
   CASE iSDOLoop:
             -
             -
             -
             -
             -
             -
             -
             -
   END CASE.
  END.
END.
/
Warning [./abl/test.p line 19, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 21, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 23, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 25, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 27, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 29, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 31, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.
Warning [./abl/test.p line 33, col 29]: Preprocessor evaluation of expression '2 < ~{&num~}' failed, returning false.

#2 Updated by Alexandru Lungu about 1 year ago

  • Related to Bug #6308: post string literal alternative coding quirk in 4GL preprocessor added

#3 Updated by Stefan Vieru about 1 year ago

#4 Updated by Greg Shah 7 months ago

  • topics 4GL Preprocessor added

#5 Updated by Greg Shah 16 days ago

Testcase added:

keeptildes_escaped_braces_in_define is committed and reproduces the defect exactly:

OE : WHEN 6 THEN message 5 6.
FWD: (empty line)

It also confirms the issue's own observation that this is keepTildes-only: against the no-keeptildes output the same baseline matches. Input:

define variable ii as integer no-undo init 6.
&SCOPED-DEFINE NumTTs 5
&SCOPED-DEFINE fetchTT &IF {&NumTTs} < ~{&num~} &THEN~
 WHEN ~{&num~} THEN message {&NumTTs} ~{&num~}.~
 &ENDIF
&SCOPED-DEFINE num 6
case ii:
{&fetchTT}
end case.

The CASE wrapper is deliberate: it makes the expansion valid 4GL so the OE listing is complete rather than truncated at a compile error.

#6 Updated by Paula Păstrăguș 15 days ago

  • Related to Bug #11835: -keeptildes keeps escape text for macro-expanded content, where OE emits only the byte added

Also available in: Atom PDF