Error "Parameter type label ambiguous (CODE or DATA)" using BIND in 11.1 (works with 11.0)

This code compiles fine with C11.0 but fails to compile with C11.1:

  PROGRAM

Class1              CLASS,TYPE
Function1             PROCEDURE,STRING
                    END

  MAP 
Function1 PROCEDURE,STRING
  END
  
  CODE
  
  BIND('Function1',Function1)    
  
Class1.Function1    PROCEDURE!,STRING
  CODE  
  RETURN ''
    
Function1           PROCEDURE!,STRING
  CODE  
  RETURN ''

The error is: Parameter type label ambiguous (CODE or DATA) - Test.clw:13,20

Probably it’s related to this fix in Build 11.1.13744: FIX: Compiler: incorrect code could be generated for a BIND statement.

The obvious solution is to rename one or the other function, but as both are widely used in a relatively large code base (Function1 is a bindable stub used in FRB reports to call the class function), I wonder if anyone had this problem before and found a simpler workaround.

This is a minimal test project: BindProcMethod.zip (1.2 KB)

A workaround is to create another stub in a local MAP just to let BIND work


  BIND('Function1',locFunction1)    
  ...

locFunction1           PROCEDURE!,STRING
  CODE  
  RETURN Function1()

Another workaround is to use a reference to a procedure

  PROGRAM

Class1              CLASS,TYPE
Function1             PROCEDURE,STRING
                    END

  MAP 
Function1   PROCEDURE,STRING
Function1Type   PROCEDURE,STRING,TYPE
  END

refFunction1 &Function1Type
  
  CODE
  
  refFunction1 &= Function1  
  BIND('Function1',refFunction1)    
  MESSAGE(EVALUATE('Function1()'))

Function1           PROCEDURE!,STRING
cl1                   Class1
  CODE  
  RETURN cl1.Function1()

Class1.Function1    PROCEDURE!,STRING
  CODE  
  RETURN '123'

I can only confirm that I see the same problem you are experiencing

I appreciate this answer as it may answers a similar question I had about how to assign a function to a class and execute it later on within a method. I will play around with your sample. Thanks.

Jeff

I reported this (43441) and now has status Bug confirmed.

3 Likes

One more reason to delay C12 for a half of year.