Project

General

Profile

Bug #2548

buffer/tables names are too aggressively matched in preference to other names

Added by Greg Shah about 9 years ago. Updated about 9 years ago.

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

0%

billable:
No
vendor_id:
GCD
case_num:

Related issues

Related to User Interface - Feature #1790: implement menu support Closed

History

#1 Updated by Greg Shah about 9 years ago

As reported in #1790 note 275 by Vadim Gindin:

From time to time I'm facing with the following conversion problem. Look at the following procedure:

def button b.
def frame f b.
def var h as widget-handle.
assign h = b:handle.

I'm getting the following error when trying to convert this procedure:

------------------------------------------------------------------------------
Code Conversion Annotations
------------------------------------------------------------------------------

Optional rule set [customer_specific_annotations_prep] not found.
./menu/but_handle.p
EXPRESSION EXECUTION ERROR:
---------------------------
throwException(sprintf(spec, bufname, reftype), this)
^  { Cannot find buffer named p2j_test.book_p2j_test.book for ref type 21! [FIELD_INT id <257698037802> 0:0] }
---------------------------
Elapsed job time:  23:00:00.810
ERROR:
java.lang.RuntimeException: ERROR!  Active Rule:
-----------------------
      RULE REPORT      
-----------------------
Rule Type :   WALK
Source AST:  [ book-id ] BLOCK/STATEMENT/DEFINE_FRAME/FORM_ITEM/FIELD_INT/ @0:0 {257698037802}
Copy AST  :  [ book-id ] BLOCK/STATEMENT/DEFINE_FRAME/FORM_ITEM/FIELD_INT/ @0:0 {257698037802}
Condition :  throwException(sprintf(spec, bufname, reftype), this)
Loop      :  false
--- END RULE REPORT ---

    at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1006)
    at com.goldencode.p2j.convert.ConversionDriver.processTrees(ConversionDriver.java:973)
    at com.goldencode.p2j.convert.ConversionDriver.back(ConversionDriver.java:834)
    at com.goldencode.p2j.convert.ConversionDriver.main(ConversionDriver.java:1799)
Caused by: com.goldencode.expr.ExpressionException: Expression execution error @1:1 [FIELD_INT id=257698037802]
    at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:225)
    at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:160)
    at com.goldencode.p2j.pattern.PatternEngine.apply(PatternEngine.java:1515)
    at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1413)
    at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1361)
    at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:974)
    ... 3 more
Caused by: com.goldencode.expr.ExpressionException: Expression execution error @1:1
    at com.goldencode.expr.Expression.execute(Expression.java:434)
    at com.goldencode.p2j.pattern.Rule.apply(Rule.java:401)
    at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:640)
    at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:609)
    at com.goldencode.p2j.pattern.Rule.apply(Rule.java:440)
    at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:640)
    at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:609)
    at com.goldencode.p2j.pattern.Rule.apply(Rule.java:440)
    at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:640)
    at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:609)
    at com.goldencode.p2j.pattern.Rule.apply(Rule.java:440)
    at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:640)
    at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:609)
    at com.goldencode.p2j.pattern.Rule.apply(Rule.java:440)
    at com.goldencode.p2j.pattern.RuleContainer.apply(RuleContainer.java:530)
    at com.goldencode.p2j.pattern.RuleSet.apply(RuleSet.java:1)
    at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:212)
    ... 8 more
Caused by: com.goldencode.p2j.pattern.CommonAstSupport$UserGeneratedException: Cannot find buffer named p2j_test.book_p2j_test.book for ref type 21! [FIELD_INT id <257698037802> 0:0]
    at com.goldencode.p2j.pattern.CommonAstSupport$Library.throwException(CommonAstSupport.java:2227)
    at com.goldencode.expr.CE3328.execute(Unknown Source)
    at com.goldencode.expr.Expression.execute(Expression.java:341)
    ... 24 more

Because of some reason b is treated as FIELD_INT. Lets look at corresponding AST:

    <ast col="0" id="257698037767" line="0" text="statement" type="STATEMENT">
      <annotation datatype="java.lang.Boolean" key="reachable" value="true"/>
      <ast col="1" id="257698037768" line="3" text="def" type="DEFINE_FRAME">
        <annotation datatype="java.lang.Boolean" key="reachable" value="true"/>
        <ast col="11" id="257698037771" line="3" text="f" type="SYMBOL">
          <annotation datatype="java.lang.Boolean" key="reachable" value="true"/>
        </ast>
        <ast col="13" id="257698037774" line="3" text="b" type="TABLE">
          <annotation datatype="java.lang.String" key="schemaname" value="p2j_test.book"/>
          <annotation datatype="java.lang.String" key="bufname" value="p2j_test.book"/>
          <annotation datatype="java.lang.String" key="dbname" value="p2j_test"/>
          <annotation datatype="java.lang.Long" key="recordtype" value="12"/>
          <annotation datatype="java.lang.Boolean" key="reachable" value="true"/>
        </ast>
      </ast>
    </ast>

b ast node has type "TABLE"..

Here is the *.parser file:

block [BLOCK] @0:0
   statement [STATEMENT] @0:0
      def [DEFINE_BUTTON] @1:1
         b [SYMBOL] @1:12
   statement [STATEMENT] @0:0
      def [DEFINE_FRAME] @3:1
         f [SYMBOL] @3:11
         b [TABLE] @3:13
   statement [STATEMENT] @0:0
      def [DEFINE_VARIABLE] @5:1
         h [SYMBOL] @5:9
         as [KW_AS] @5:11
            widget-handle [KW_WID_HAND] @5:14
   statement [STATEMENT] @0:0
      assign [KW_ASSIGN] @7:1
         = [ASSIGN] @7:10
            h [VAR_HANDLE] @7:8
            expression [EXPRESSION] @0:0
               : [COLON] @7:13
                  b [WID_BUTTON] @7:12
                  handle [ATTR_HANDLE] @7:14

b here has also type "TABLE". It looks like parser problem..

I faced with this error before with other procedures. Could you try to convert this procedure? Will you get the same error?

#2 Updated by Greg Shah about 9 years ago

From #1790 note 276 by Constantin Asofiei:

This is a problem with the name resolution: in 4GL, a table can be abbreviated using only the first letter, so a find first b. will find you the first book. I think P2J is too aggressive when resolving these names; looks like 4GL looks into table names only if the name is used in a context where a table name is needed (i.e. find first b.). The define button b. is not a context where a table can be used, so the button will be created in 4GL.

For now, go around this problem by renaming your button to something else (i.e define button btn.).

Also available in: Atom PDF