Maybe a silly question, but I find that:
Code: Select all
union UNO
as OBJECT o
end union
#print typeOf(UNO.o) ''prints UNO, rather than OBJECT
Code: Select all
union UNO
as OBJECT o
end union
#print typeOf(UNO.o) ''prints UNO, rather than OBJECT
Your remark match with a known feature request:Tourist Trap wrote:So as said in the commented part, I would be expecting to be returned the object type (of o) rather that the parent type. Is there a reason for this that I obviously miss?
- Compiling your code with the current fbc 1.08 now provides:Version 1.08.0
.....
[added]
.....
- sf.net feature request #293: allow len/sizeof/typeof for UDT members without expression
.....
- Extract of the TYPEOF documentation page:Compiler output:
C:\Users\.....\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas(2) error 163: Fields with constructors cannot be part of UNION's or nested TYPE's in 'as OBJECT o'
OBJECT
.....
TypeOf also supports passing any intrinsic data type, or user-defined type (and its data fields for fbc version >= 1.08), not only variables defined as those types. Also supported are expressions, the type is inferred from the expression (much like Var).
.....
Yes, however the same issue holds whatever the type behavior regarding the constructor, for an Integer for instance.badidea wrote:That code gives two errors here as welll:
test.bas(2) error 163: Fields with constructors cannot be part of UNION's or nested TYPE's in 'as OBJECT o'
test.bas(5) error 7: Expected ')', found '.' in '#print typeOf(UNO.o) ''prints UNO, rather than OBJECT'
Thanks a lot fxm,fxm wrote:- Extract of the TYPEOF documentation page:Compiler output:
C:\Users\.....\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas(2) error 163: Fields with constructors cannot be part of UNION's or nested TYPE's in 'as OBJECT o'
OBJECT.....
TypeOf also supports passing any intrinsic data type, or user-defined type (and its data fields for fbc version >= 1.08), not only variables defined as those types. Also supported are expressions, the type is inferred from the expression (much like Var).
.....