Incompatible data types in expression or assignment (using O

Posted by dbeavon on 22-Aug-2017 19:12

Anyone ever see this type of error?  It is a compiler-related message I saw today while running some OO code.


** Incompatible data types in expression or assignment. (223)
** ./app/Production/Treating/ScannedCharges/TreatingCharge.cls Could not understand line 147. (196)
RETURN statement in user defined function or method 'NewCreateChargeOperation' is not type compatible with the function or method definition. (2782)
** ./app/Production/Treating/ScannedCharges/TreatingCharge.cls Could not understand line 148. (196)
** Incompatible data types in expression or assignment. (223)
** ./app/Production/Treating/ScannedCharges/TreatingCharge.cls Could not understand line 162. (196)
Could not locate method 'PerformScanningOperation' with matching signature in class 'app.Production.Treating.ScannedCharges.MobileOps.CreateChargeOperation'. (14457)
** ./app/Production/Treating/ScannedCharges/TreatingCharge.cls Could not understand line 379. (196)

As near as I can tell, these are 100% bogus errors saying my OO types are incompatible.  For some reason I'm having difficulty pinning down a repro but it has to do with inheritance where subclasses override a method in a base class, and the OE compiler then decides that the types are not compatible, even though they are.  In the example above, the compiler says it could not locate method 'PerformScanningOperation' with a matching signature but it is present.

There are a number of wierd work-arounds that are as hard to explain as the original bug.  For example if I have a method like so:

METHOD PRIVATE app.Production.Treating.ScannedCharges.MobileOps.CreateChargeOperation NewCreateChargeOperation(INPUT p_BranchCode AS CHARACTER):

DEFINE VARIABLE v_Operation AS CreateChargeOperation NO-UNDO.
v_Operation = NEW app.Production.Treating.ScannedCharges.MobileOps.CreateChargeOperation(p_BranchCode).
RETURN v_Operation.

END METHOD.


... Then the fix may be to change the DEFINE VARIABLE statement to (fully qualified class name):

DEFINE VARIABLE v_Operation AS app.Production.Treating.ScannedCharges.MobileOps.CreateChargeOperation  NO-UNDO.

 

Then the compiler appears happy for a little while longer, but eventually chokes somewhere else.

Things get even more weird when I tried to isolate the problem.  It started in a state-reset appserver session on HP-UX IA64 on version 11.6.3.013.

  • It totally goes away if I *compile* all the source to r-code before trying to use it
  • It goes away if I switch from state-reset to state-free (even if I delete r-code again)
  • It goes away if I try running the code in the editor (even if I delete r-code)
  • It goes away if I delete r-code and move to Windows 64 (things work on state-reset and state free)

So the problem seems to be specific to using an OO inherited class (1) on HP-UX (2) without compiling r-code first, and (3) only in state-reset appservers.

Any tips would be appreciated from those of you who are trying to use OO in ABL.

Posted by Evan Bleicher on 23-Aug-2017 08:53

Hi David:

From a Language perspective, you are identifying that ABL code compiles successfully on non-HP-UX systems and fails to compile on HP-UX.  Given that observation, your conclusion to contact Progress Technical Support and log an issue is appropriate.  OpenEdge Development would need to investigate this scenario to understand why your code does not compile on HP-UX.  From the compilation perspective, the operating mode of the AppServer (state-reset vs. state-free) should be unrelated to the issue you are raising.

Thanks

All Replies

Posted by agent_008_nl on 22-Aug-2017 22:47

Never seen it. As you know I don't use inheritance, when I refactor legacy I remove it. Maybe you could use parameter objects (eventually google for the "parameter object" refactoring)? New your objects in the constructor of them, assign them to private set public get properties. Easy to pass around a param object: no list of params in a certain order needed, easy to maintain (more objects needed? just add them to the param object).

Posted by marian.edu on 23-Aug-2017 01:34

Stefan, he only seems to have one character parameter as input to that method so I would find it hard to extract that to a ‘parameter object’ :)


With OO addition to 4GL the compiler have to become smarter to cope with the strong typing feature that’s expected at compile time, thing is this is probably not an easy task when there are cross references so the compiler need to be able to check if every object referenced compiles. It might just be a bug on that specific environment although there might just be a simple PROPATH issue, there are also ways to help the compiler if you really need to run with compile on-the-fly although doing that in ‘production’ doesn’t sounds like a good idea. 

To start with I wouldn’t use a namespace like ‘app.Production’, the ‘app’ prefix doesn’t serve any purpose and having the ‘environment’ part of the namespace just doesn’t make any sense - use PROPATH for that if need be. Creating classes with the same name in different packages (especially if one inherits the other) in almost never a good idea, you can’t import both so one will have to be fully referenced making it easier for the fellow developers to get confused and mix them :)

Programming to the interface is not a bad idea either, since there is no additional logic there the compiler usually finds it easier to compile interfaces so instead of using classes for parameters define interfaces and use those as parameters in methods definition.

Marian Edu

Acorn IT 
+40 740 036 212

Posted by agent_008_nl on 23-Aug-2017 03:24

Grr Marian, is it really so difficult to see what I mean? You can just skip commenting my remarks also if you only care to provide negitive criticism. Do something useful instead. Just providing your tips can be enough. I do not mean to "use the parameter object refactoring" but look into this refactoring to see what a parameter object is (if unknown to the reader) and for what you can use it. Maybe it is not an interesting solution in this case, I have not seen the application as a whole, only a small piece of code.

Posted by Torben on 23-Aug-2017 03:54

Could be caused by different definitions of class CreateChargeOperation

Are you hitting exact same class when writing fully quallified class name app.Production.Treating.ScannedCharges.MobileOps.CreateChargeOperation?

If not then you will get error!

Solution can be to cast return to correct class.

Posted by dbeavon on 23-Aug-2017 07:52

Thanks for the tips Marian,  I am very open to the possibility that it is a platform-specific issue on HP-UX since there have been quite a number of those.  In fact I've almost stopped developing on HP-UX altogether since it seems to be such an odd duck.  I wouldn't go near it at all except for the fact that we still use it in production.

Your other tips about the possibility of PROPATH and namespace problems are also interesting.  They might explain why the on-the-fly compilation was a little bit happier when I started to use fully-qualified namespaces for my class names.  I thought the USING statements would be enough to resolve the location of my classes for the compiler (especially since Progress requires that class names and namespaces align with filenames and paths).

It sounds like you might have had some of these types of experiences yourself.  Have you ever come across code that Progress OE didn't accept when using "on-the-fly" compilation but was happy to compile into r-code?  This may be a first for me.  The weirdest part (IMHO) was the (1) platform-specific behavior, and the (2) difference in behavior between state-reset appserver and running the same code in the editor (whereby neither scenario uses r-code).  But then, like you said, I may be overlooking some subtle environment variable or another subtle environment-related factor.

I was hoping someone would pipe in and say they know about a specific KB/bug related to either the message "incompatible data types" or the message that seems to preceed it ("Could not locate method...with matching signature in class").  But I suppose that the problem my involve *both* the use of  OO *and* HP-UX, in which case I may be on my own. ;)  I will package up the project and send it off to support when I have some spare time.  Hopefully Progress still has an HP-UX server sitting around somewhere.

Fortunately we always run compiled classes in production.  I guess for now I will also have to compile in development too.

Posted by dbeavon on 23-Aug-2017 08:00

Thanks everyone for the tips.  If those specific messages don't look familiar to anyone, then I will have to go to Progress with this problem.  One motivation I had in creating this posting was to try to generate another search result for google.  If you search for these things in relation to OE ...

  • "Incompatible data types in expression or assignment"
  • "Could not locate method ... with matching signature in class"

You get very little.  I'm not sure exactly why that might be, but at least now there will be one more search result.  Perhaps sometime soon there will also be a KB as well...

Posted by Brian K. Maher on 23-Aug-2017 08:06

Be sure to include site:knowledgebase.progress.com in the search.  When I search for "Incompatible data types in expression or assignment" and include the site: string I get three pages of articles returned.

Posted by Stefan Drissen on 23-Aug-2017 08:07

Since you're on a *nix platform - could incorrect casing of classes vs their file names be an issue?

Posted by Tim Kuehn on 23-Aug-2017 08:33

I've had repeated issues in PDS w/class caching - particularly when I move a class from one location to another. For example I had a class in x/y/c.cls that I moved to x/y/z/c.cls - and PDS'll still remember the old location and put in a USING  statement that points to the old location.

When it goes to compile it naturally doesn't find it and I get the same kind of "Data type" error reported by the OP. I've had to re-arrange the USING statement to hold the correct location and put it before a USING that points to some other code in the old location.

Posted by Evan Bleicher on 23-Aug-2017 08:53

Hi David:

From a Language perspective, you are identifying that ABL code compiles successfully on non-HP-UX systems and fails to compile on HP-UX.  Given that observation, your conclusion to contact Progress Technical Support and log an issue is appropriate.  OpenEdge Development would need to investigate this scenario to understand why your code does not compile on HP-UX.  From the compilation perspective, the operating mode of the AppServer (state-reset vs. state-free) should be unrelated to the issue you are raising.

Thanks

Posted by dbeavon on 05-Sep-2017 18:44

I finally figured out what I had done wrong that confused the appserver so badly.

I had created my appserver by copying from another and ended up with a bad PROPATH.

[UBroker.AS.dev_lumbertrack_dkb]
    autoStart=1
    portNumber=3107
    PROPATH=${PROPATH}:${OLDWORKDIR}
    ...
    uuid=1234108e8ddd6422:122206:103300801e9:-8000
    workDir=${NEWWORKDIR}

... where $OLDWORKDIR was a bad/duplicate code location that was not applicable to this new copy of the appserver.  When I had copied from another appserver's configuration, I had fixed the "workDir" to use ${NEWWORKDIR} (and I fixed other things like portNumber, and uuid) but I had apparently overlooked the PROPATH....  Turns out that we don't really need to specify the working directory in the PROPATH anyway.

As a result of the poorly copy/pasted config, the $OLDWORKDIR location was occasionally being used for some of the executing code (especially when it had r-code available in there - and the class names weren't being fully qualified in the calling source code at $NEWWORKDIR ).

The two locations for ABL programs ($OLDWORKDIR and $NEWWORKDIR) are pretty far removed from one another in the file system, but were unfortunately both accessible from the save development machine.  There wasn't much in the appserver log that alerted me to the problem, even though I imagine that the flow of control was probably bouncing back and forth between two entirely different sets of code (albeit they'd sync up with each other on certain days , once my programming changes were pulled from source control).

I suppose if I had configured the appserver's *broker* log to dump all its properties, including the PROPATH, I might have eventually seen the problem.  I only found the problem after rebuilding my state-reset appserver line-by-line.  As Evan had pointed out, state-reset and state-free should never have been behaving differently in the first place.  Apparently the reason for difference in behavior was that was that only one of them had a bad PROPATH.

Thanks for the tips everyone.  My first suspicion was a bug in HP-UX because there have been a number of HP-UX-specific problems over the years.  I suppose next time I see differences between Windows and HP-UX, I will be a bit slower to point fingers.

This thread is closed