Harbour classes engine bug

229 views
Skip to first unread message

Antonio Linares

unread,
Feb 5, 2024, 3:27:40 AMFeb 5
to Harbour Developers
Please test this code:

#include "hbclass.ch"

function Main()
   local oTest := Test()
   oTest:any( 123 )
   ? oTest:any
return nil

CLASS Test
   DATA any
ENDCLASS

As you can see the Harbour classes engine is accepting the use of a DATA as a METHOD, even supplying it parameters, and it does  not generates any error.

I do appreciate if you run it to confirm the bug. We should make Harbour generate an error in such case.

many thanks

Enrico Maria Giordano

unread,
Feb 5, 2024, 4:21:19 AMFeb 5
to harbou...@googlegroups.com

Angel Salom

unread,
Feb 6, 2024, 5:10:47 AMFeb 6
to Harbour Developers
I get NIL with Harbour 3.2.0dev (r2008190002)

Lailton Fernando Mariano

unread,
Feb 6, 2024, 8:47:54 AMFeb 6
to Harbour Developers
Hi Antonio,

yes, it works but the expected is an error and not the return as nil.

Aleksander Czajczynski

unread,
Feb 8, 2024, 2:54:14 AMFeb 8
to harbou...@googlegroups.com
Hello!

DATA / VAR declaration generates ACCESS method "any" and ASSIGN method
"_any", AFAIK this is Clipper +Class(y) behavior which we are based on.

o:call() is exactly equal to o:call, so ACCESS method is really a
METHOD. Xbase++ separates those i think.

If you change your class to protect your internal variables, this
becomes a bit less of an issue.

CLASS Test
PROTECTED:
DATA any
ENDCLASS

Then call ends up with an error

Error BASE/42 Scope violation (protected): TEST:ANY

Don't know if someone is able to fix this, without heavy changes and
compatibility issues. A redesign should rather target a strongly typed
alternative class system, if replaceable, then something like #include
"hbclass2.ch".

Best regards, Aleksander
> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to harbour-deve...@googlegroups.com
> <mailto:harbour-deve...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/harbour-devel/033d0759-7fae-4026-9536-810c5b4c6501n%40googlegroups.com
> <https://groups.google.com/d/msgid/harbour-devel/033d0759-7fae-4026-9536-810c5b4c6501n%40googlegroups.com?utm_medium=email&utm_source=footer>.


Reply all
Reply to author
Forward
0 new messages