Bug #10597
[Regression] extent field in form fails conversion
100%
History
#1 Updated by Dănuț Filimon 10 months ago
define temp-table tt1 field f1 as integer extent 5.
form tt1.f1.
assign
tt1.f1[1]:font = 5
tt1.f1[2]:font = 5
tt1.f1[3]:font = 5.
doesn't convert properly.
I tested trunk/16163, trunk/15900 and trunk/15850. I can't revert anymore because of brz: ERROR: Key b'session-20250108064915-vs6vazfmsbtg5ovr-1' is already present in map, but it looks like it was here for a while because 7156e which is based on trunk/15726 was working. This regression was most likely introduced in trunk/15726-15850. More details in #10566-12 and #10566-13 on how the code should actually look like.
#3 Updated by Dănuț Filimon 10 months ago
Work on #10566 can't continue unless #10597 is fixed.
#4 Updated by Stefanel Pezamosca 10 months ago
This hasn’t worked for temp-tables for a long time, even before 15726. The issue is that temp-tables use the conversion logic for normalized extent fields, which is broken in this case.
Before 7020, denormalized extents had their own logic, so extent fields in persistent tables were converted correctly. After 7020, both persistent and temp-tables started using the same code that was previously used only for temp-tables. As a result, 7020 reintroduced an old bug with normalized extents, previously affecting only temp-tables, into persistent tables as well.
#5 Updated by Dănuț Filimon 10 months ago
Nice find Stefanel! I modified the scenario to use temp-tables since it was easier, but the original one uses persistent tables.
#6 Updated by Stefanel Pezamosca 10 months ago
- % Done changed from 0 to 10
- Status changed from New to WIP
- Assignee set to Stefanel Pezamosca
So, this works if we remove the assign:
define temp-table tt1 field f1 as integer extent 5. form f1. assign f1[1]:font = 5. f1[2]:font = 5.Being converted to:
0.setFont(new integer(5));
frame0.widgetF1Array1().setFont(new integer(5));
So the assign breaks something.#7 Updated by Stefanel Pezamosca 10 months ago
So, the issue I see now is that the widget AST saved in the frame widgets list looks like this:
ref: f1 [FIELD_CHAR]:12884901960 @1:6
[ [LBRACKET]:12884901961 @0:0
1 [NUM_LITERAL]:12884901962 @0:0
node: f1 [FIELD_CHAR]:12884901906 @3:8
[ [LBRACKET]:12884901907 @3:10
expression [EXPRESSION]:12884901908 @0:0
1 [NUM_LITERAL]:12884901909 @3:11
They are checked with node.getChildAt(0).compareWith(ref.getChildAt(0)) at some point to search for the frame of the widget, but it fails.This worked for persistent tables (before #7020) extent fields in
denorm_extents mode because LBRACKET was replaced with some annotations.#8 Updated by Stefanel Pezamosca 10 months ago
- % Done changed from 10 to 100
- File 10597a.patch
added - Status changed from WIP to Review
- reviewer Ovidiu Maxiniuc added
I finally figured that this issue was fixed in the past, but only for <function name="search_widget"> (<!-- locate widget in the defined frames and return reference to frame -->). This condition is also needed in <function name="search_widget_in_outer_scopes"> (<!-- search widget in open scopes -->).
=== modified file 'rules/annotations/frame_scoping.rules'
--- old/rules/annotations/frame_scoping.rules 2025-03-25 11:48:45 +0000
+++ new/rules/annotations/frame_scoping.rules 2025-09-22 11:44:35 +0000
@@ -4591,6 +4591,12 @@
txt1.equals(txt2)
<action>res = frame</action>
</rule>
+
+ <!-- check item of EXTENT field -->
+ <rule>node.getNumImmediateChildren() == 1 and
+ txt1.equals(txt2)
+ <action>res = frame</action>
+ </rule>
</rule>
<rule>is_w and nm.equals(ref.text.toLowerCase())
This fixes the issue.I created task branch 10597a and committed the patch in revision 16177.
Please review!
Andrei, can you test this patch for #10566-12 ?
#10 Updated by Ovidiu Maxiniuc 10 months ago
- Status changed from Review to Internal Test
Stefanel Pezamosca wrote:
I created task branch 10597a and committed the patch in revision 16177.
Please review!
The changes make sense. Please continue with testing.
#11 Updated by Stefanel Pezamosca 10 months ago
- Status changed from Internal Test to WIP
- % Done changed from 100 to 90
There are other cases that need to be addressed. Andrei notified me that the conversion failed with the same output. So, I modified the testcase by adding with frame and the fix in 10597a does not work for this.
define temp-table tt1 field f1 as integer extent 5.
form
f1
with frame main01.
assign
f1[1]:font = 5
f1[2]:font = 5
f1[3]:font = 5
f1[4]:font = 5
f1[5]:font = 5.
#12 Updated by Stefanel Pezamosca 10 months ago
- % Done changed from 90 to 100
- File 10597a_v2.patch
added - Status changed from WIP to Review
NUM_LITERAL node was not marked with the is-literal annotation.I committed the fix in 10597a revision 16178.
array_expansion.rules: Mark createdprog.num_literalnodes withis-literalannotation.
I also attached the full patch for 10597a.
#14 Updated by Ovidiu Maxiniuc 10 months ago
- Status changed from Review to Internal Test
I am OK with the latest changes from 10597a (I think there is is typo in note 12: 10579a).
#15 Updated by Stefanel Pezamosca 10 months ago
No more issues found. I believe this is ready to be merged into trunk.
#16 Updated by Stefanel Pezamosca 8 months ago
Can this be merged to trunk?
#17 Updated by Alexandru Lungu 8 months ago
- Status changed from Internal Test to Merge Pending
Please merge 10597a to trunk now.
#18 Updated by Stefanel Pezamosca 8 months ago
- Status changed from Merge Pending to Test
Branch 10597a was merged into trunk as rev. 16275 and archived.
#19 Updated by Dănuț Filimon 8 months ago
I ran a conversion with trunk/16293 for #10566 and the issue remained. Stefanel, did you also test the scenario using persistent tables?
#20 Updated by Stefanel Pezamosca 8 months ago
Dănuț Filimon wrote:
I ran a conversion with trunk/16293 for #10566 and the issue remained. Stefanel, did you also test the scenario using persistent tables?
I double checked the testcases noted in this task with temp-tables and persistent tables. There was no issue. Please double check if you have the required rules changes or the correct p2j references. You can check from 10597a_v2.patch attached here.
#21 Updated by Dănuț Filimon 8 months ago
Stefanel Pezamosca wrote:
Dănuț Filimon wrote:
I ran a conversion with trunk/16293 for #10566 and the issue remained. Stefanel, did you also test the scenario using persistent tables?
I double checked the testcases noted in this task with temp-tables and persistent tables. Ther was no issue. Please double check if you have the required
ruleschanges or the correctp2jreferences. You can check from10597a_v2.patchattached here.
The patch is already in the trunk from the instance, I'll give it the benefit of the doubt and restart conversion for that module.
#22 Updated by Stefanel Pezamosca 8 months ago
Dănuț Filimon wrote:
The patch is already in the trunk from the instance, I'll give it the benefit of the doubt and restart conversion for that module.
You could also try incremental.
#25 Updated by Stefanel Pezamosca 6 months ago
- % Done changed from 100 to 90
- Status changed from Test to WIP
I got notified that the change from this task caused another regression that can be reproduced by this testcase:
DEFINE TEMP-TABLE ttm
FIELD ext AS INTEGER EXTENT 4 format "->,>>>,>>9".
CREATE ttm.
ASSIGN
ttm.ext[1] = 0
ttm.ext[2] = 0
ttm.ext[3] = 0
ttm.ext[4] = 0.
form
space(3) ttm.ext[1] label "ext1" format "9"
space(3) ttm.ext[2] label "ext2" format "9"
space(3) ttm.ext[3] label "ext3" format "9"
space(3) ttm.ext[4] label "ext4" format "9"
with frame frArc
with centered side-label row 3.
ttm.ext[4] = 0.
display ttm.ext[4] with frame frarc.
repeat:
update ttm.ext[4] with frame frarc.
message "You entered: " ttm.ext[4].
if input ttm.ext[4] > 3 then do:
message "greater than 3".
end.
pause 1 no-message.
end.
The problem is a pretty obvious conversion regression in this case:
With trunk 16275:
if (_isGreaterThan(frArcFrame.getExtArray0(), 3)) and extArray0.setTable("ttm");(in StartFrArc.java frame class)Without:
if (_isGreaterThan(frArcFrame.getExtArray3(), 3)) and extArray3.setTable("ttm");(in StartFrArc.java frame class)
I already understand that it is because of this rules because they are not checking for the extent index just the name:
+ <!-- check item of EXTENT field --> + <rule>node.getNumImmediateChildren() == 1 and + txt1.equals(txt2) + <action>res = ref</action> + </rule>I need to get and compare the indices also. Working on it.
#26 Updated by Stefanel Pezamosca 6 months ago
- % Done changed from 90 to 100
- File 10597b.patch added
I have a fix prepared in 10597b.patch and attached here. I will commit to a branch for review tomorrow after running some more tests from #10597.
Delia, please check it out also.
#27 Updated by Stefanel Pezamosca 6 months ago
- File deleted (
10597b.patch)
#28 Updated by Stefanel Pezamosca 6 months ago
- File 10597b.patch
added - Status changed from WIP to Review
Previous patch had a NPE.
I created task branch 10597b from trunk revision 16350.
Committed the fix in revision 16351. Please review!
#29 Updated by Delia Mitric 6 months ago
Stefanel Pezamosca wrote:
Previous patch had a NPE.
I created task branch 10597b from trunk revision 16350.Committed the fix in revision 16351. Please review!
I've checked it by doing the incremental conversion on the customer app and also on the testcase.The issue is solved 🥳
#30 Updated by Ovidiu Maxiniuc 6 months ago
- Status changed from Review to Internal Test
Review of 10597b / r16351.
I think the code is OK 👍.
My OCD: there is a misaligned variable definition at line 4271 😠.
#31 Updated by Stefanel Pezamosca 6 months ago
Ovidiu Maxiniuc wrote:
My OCD: there is a misaligned
variabledefinition at line 4271 😠.
I'll fix it 😅.
I'll continue with conversion testing.
#32 Updated by Stefanel Pezamosca 6 months ago
All the testcases noted in #10597 passed. The conversion issue found at the customer app is solved. I also compared conversion output for other apps I have available.
If no objections, 10597b can be merged to trunk.
#35 Updated by Constantin Asofiei 6 months ago
- Priority changed from Normal to Urgent
- Status changed from Internal Test to WIP
- % Done changed from 100 to 90
Stefanel, there is a regression in trunk in rev 16275:
def var ch as char. def var j as int. def var i as int extent 5. def temp-table tt1 field f1 as int extent 5. find first tt1. form tt1.f1 with frame f1. form i with frame f2. ch = input i[j]. ch = input tt1.f1[j]. if input tt1.f1[j] = j then message "good". if input i[j] = j then message "good". ch = input i[2]. ch = input tt1.f1[2]. if input tt1.f1[2] = j then message "good". if input i[2] = j then message "good".
Instead of emitting getF1Array or getF1Array1 it emits getF1Array0; this for some reason happens only for temp-table extent fields which are part of a frame. The root cause is this rule added in search_widget_in_frame:
<!-- check item of EXTENT field -->
<rule>node.getNumImmediateChildren() == 1 and
txt1.equals(txt2)
<action>res = ref</action>
</rule>
For some reason this does not match on the LPARENS child, although this is done in a prior rule:
<rule>node.getChildAt(0) != null and
ref.getChildAt(0) != null and
txt1.equals(txt2) and
node.getChildAt(0).compareWith(ref.getChildAt(0))
<action>res = ref</action>
</rule>
#36 Updated by Stefanel Pezamosca 6 months ago
- Status changed from WIP to Internal Test
- % Done changed from 90 to 100
Constantin Asofiei wrote:
Stefanel, there is a regression in trunk in rev 16275:
[...]Instead of emitting
getF1ArrayorgetF1Array1it emitsgetF1Array0; this for some reason happens only for temp-table extent fields which are part of a frame. The root cause is this rule added insearch_widget_in_frame:
[...]For some reason this does not match on the LPARENS child, although this is done in a prior rule:
[...]
Did you checkout 10597b? It should fix the issue. It is not in trunk yet. A similar issue was already discussed and worked on, check the previous notes from #10597-25.
#37 Updated by Constantin Asofiei 6 months ago
Thanks for the heads up. The fix in 10597b has a regression: it creates a 3rd "frame0" frame for the input i[j]. cases.
#38 Updated by Stefanel Pezamosca 6 months ago
- Status changed from Internal Test to WIP
#39 Updated by Stefanel Pezamosca 6 months ago
- Status changed from WIP to Review
I fixed the issue. The problem was that when doing txt1.equals(txt2), in some cases txt1 was just i, while txt2 was i[1], i[2], etc.
Previously, there was a variable dyn used to avoid computing txt2 in search_widget when the first node had a dynamic index. I had removed it while making my changes, but I’ve now reintroduced it, which resolves the issue.
Committed the fix in 10597b revision 16352.
#40 Updated by Ovidiu Maxiniuc 6 months ago
- Status changed from Review to Internal Test
The changes look good.
#41 Updated by Constantin Asofiei 6 months ago
- Status changed from Internal Test to Merge Pending
Stefanel, please merge 10597b to trunk now.
#42 Updated by Stefanel Pezamosca 6 months ago
- Status changed from Merge Pending to Test
Branch 10597b was merged into trunk as rev. 16368 and archived.