Bug #4423
Incorrect buffer scoping when same buffer name used as a parameter to internal procedure
100%
History
#1 Updated by Roger Borrello over 4 years ago
General¶
Conversion error occurs when dealing with a shared buffer name that also happens to be defined as a parameter within an internal procedure.
Update: We completed regression on the 4207a-11341 revision.
P2J Branch¶
This is being handled in Branch 4207a
Testcase¶
Checked into testcase_repo
as uast/shared-buffer/shared-buffer-internal-procedure.p
. Make sure you have at least Rev 2019 for correct p2j_test.df
file.
procedure whydoesthismatter: define parameter buffer mybuff for Person. end procedure. def new shared buffer mybuff for Person. find first mybuff no-error. site-id = 3. message avail mybuff.
Artifacts¶
Execution Log¶
------------------------------------------------------------------------------ Code Conversion Annotations ------------------------------------------------------------------------------ Optional rule set [customer_specific_annotations_prep] not found. ./shared-buffer/shared-buffer-internal-procedure.p Elapsed job time: 00:00:00.957 ERROR: com.goldencode.p2j.pattern.TreeWalkException: ERROR! Active Rule: ----------------------- RULE REPORT ----------------------- Rule Type : WALK Source AST: [ site-id ] BLOCK/ASSIGNMENT/ASSIGN/FIELD_INT/ @8:1 {455266533424} Copy AST : [ site-id ] BLOCK/ASSIGNMENT/ASSIGN/FIELD_INT/ @8:1 {455266533424} Condition : throwException(sprintf(spec, bufname, reftype), this) Loop : false --- END RULE REPORT --- at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1070) at com.goldencode.p2j.convert.TransformDriver.processTrees(TransformDriver.java:542) at com.goldencode.p2j.convert.ConversionDriver.back(ConversionDriver.java:562) at com.goldencode.p2j.convert.TransformDriver.executeJob(TransformDriver.java:876) at com.goldencode.p2j.convert.ConversionDriver.main(ConversionDriver.java:983) Caused by: com.goldencode.p2j.pattern.CommonAstSupport$UserGeneratedException: Cannot find buffer named p2j_test.person_p2j_test.person for ref type 21! [FIELD_INT id <455266533424> 8:1] at com.goldencode.p2j.pattern.CommonAstSupport$Library.throwException(CommonAstSupport.java:2817) at com.goldencode.expr.CE6846.execute(Unknown Source) at com.goldencode.expr.Expression.execute(Expression.java:373) at com.goldencode.p2j.pattern.Rule.apply(Rule.java:497) at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:745) at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:712) at com.goldencode.p2j.pattern.Rule.apply(Rule.java:534) at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:745) at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:712) at com.goldencode.p2j.pattern.Rule.apply(Rule.java:534) at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:745) at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:712) at com.goldencode.p2j.pattern.Rule.apply(Rule.java:534) at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:745) at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:712) at com.goldencode.p2j.pattern.Rule.apply(Rule.java:534) at com.goldencode.p2j.pattern.RuleContainer.apply(RuleContainer.java:585) at com.goldencode.p2j.pattern.RuleSet.apply(RuleSet.java:98) at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:262) at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:210) at com.goldencode.p2j.pattern.PatternEngine.apply(PatternEngine.java:1633) at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1531) at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1479) at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1034) ... 4 more
AST Snippet¶
<ast col="0" id="455266533420" line="0" text="assignment" type="ASSIGNMENT"> <annotation datatype="java.lang.Boolean" key="reachable" value="true"/> <ast col="9" id="455266533421" line="8" text="=" type="ASSIGN"> <annotation datatype="java.lang.Boolean" key="reachable" value="true"/> <ast col="1" id="455266533424" line="8" text="site-id" type="FIELD_INT"> <annotation datatype="java.lang.Long" key="oldtype" value="2781"/> <annotation datatype="java.lang.String" key="schemaname" value="p2j_test.person.site-id"/> <annotation datatype="java.lang.String" key="bufname" value="p2j_test.person"/> <annotation datatype="java.lang.String" key="dbname" value="p2j_test"/> <annotation datatype="java.lang.Long" key="recordtype" value="12"/> <annotation datatype="java.lang.String" key="name" value="site-id"/> <annotation datatype="java.lang.Long" key="type" value="410"/> <annotation datatype="java.lang.String" key="format" value=""99""/> <annotation datatype="java.util.ArrayList" key="label"> <listitem datatype="java.lang.String" value=""Site ID""/> </annotation> <annotation datatype="java.lang.String" key="columnlabel" value=""Site ID""/> <annotation datatype="java.lang.Long" key="support_level" value="16400"/> <annotation datatype="java.lang.Boolean" key="reachable" value="true"/> </ast> <ast col="0" id="455266533425" line="0" text="expression" type="EXPRESSION"> <annotation datatype="java.lang.Long" key="support_level" value="16400"/> <annotation datatype="java.lang.Boolean" key="reachable" value="true"/> <ast col="11" id="455266533426" line="8" text="3" type="NUM_LITERAL"> <annotation datatype="java.lang.Boolean" key="is-literal" value="true"/> <annotation datatype="java.lang.Long" key="support_level" value="16400"/> <annotation datatype="java.lang.Boolean" key="reachable" value="true"/> </ast> </ast> </ast> </ast>
#2 Updated by Constantin Asofiei over 4 years ago
The bufname
annotation is incorrect:
<annotation datatype="java.lang.String" key="bufname" value="p2j_test.person"/>
instead of the correct one:
<annotation datatype="java.lang.String" key="bufname" value="p2j_test.mybuff"/>
This is a parser problem.
#3 Updated by Roger Borrello over 4 years ago
Constantin Asofiei wrote:
The
bufname
annotation is incorrect:
[...]
instead of the correct one:
[...]This is a parser problem.
Correct... we had a similar situation already, when there was a FORM or DEFINE FRAME preceding. See #4207#note-2 and below.
#4 Updated by Constantin Asofiei over 4 years ago
Greg, the issue is with this code, in progress.g:procedure
like 11198:
// internal procedures propagate sym.deleteSchemaScope(true);
This propagates the p2j_test.mybuff
to the previous scope, and will prohibit the FIND
to propagate the mybuff
table buffer (and its fields).
#5 Updated by Greg Shah over 4 years ago
I think it needs to do that for regular buffer definitions, but I suspect that buffer parameters should not be propagated.
Roger: you could try to set the 3rd parameter on line 13156 to true r:record[promote, false, true]
. That is the noProp
flag and when true it will NOT propagate.
#6 Updated by Roger Borrello over 4 years ago
Greg Shah wrote:
I think it needs to do that for regular buffer definitions, but I suspect that buffer parameters should not be propagated.
Roger: you could try to set the 3rd parameter on line 13156 to true
r:record[promote, false, true]
. That is thenoProp
flag and when true it will NOT propagate.
That's line 13152 in my version. You may want to make sure you have 4207a checked out. In any case, testcase passes, and original customer code converts, too.
Any other testing I should do before checking that in?
#7 Updated by Greg Shah over 4 years ago
It probably should only be set when this is a parameter.
This change is dangerous so it will need some regression testing. It is probably best to get this done early rather than waiting for the branch to be complete.
#9 Updated by Roger Borrello over 4 years ago
- Status changed from New to WIP
- % Done changed from 0 to 100
- Estimated time set to 2.00
#10 Updated by Roger Borrello over 4 years ago
- Assignee set to Roger Borrello
- Estimated time changed from 2.00 to 8.00
#11 Updated by Greg Shah over 4 years ago
- Status changed from WIP to Test
#12 Updated by Roger Borrello about 4 years ago
Task branch 4207a was merged to trunk as revision 11344.
#13 Updated by Greg Shah about 4 years ago
- Status changed from Test to Closed