Menu

#772 Types with same name in different namespaces compare as equal

closed
dkl
None
compiler
2015-06-06
2015-04-11
Matthew
No
namespace a
  type T
    as integer i
  end type
end namespace

namespace b
  type T
    as single s
  end type
end namespace

#print typeof(a.T)
#print typeof(b.T)

#if typeof(a.T) = typeof(b.T)
  #print "a.T = b.T!"
#endif

Discussion

  • fxm (freebasic.net)

    Interesting!

    This problem is similar to that fixed in the fbc rev 0.91.0:
    The Is operator (RTTI) treated UDTs with the same identifier but from different namespaces as being equal

    Since fbc rev 0.91.0, the namespace structure is now encoded in the RTTI block where is the UDT name, and the 'Is' operator works with namespaces.

    IMHO, '#print typeof(a.T)' should return 'A.T' and '#print typeof(b.T)' should return 'B.T'.

     
  • fxm (freebasic.net)

    It's weird because everything else works well.


    Test program:

    namespace a
      type T
        as integer i = 1234
        as single s = 1.234
      end type
    end namespace
    
    namespace b
      type T
        as long i = 5678
        as double s = 5.678
      end type
    end namespace
    
    type aT as a.T
    type bT as b.t
    #print typeof(aT)
    #print typeof(bT)
    #print " "
    
    dim as aT a1
    dim as bT b1
    
    #print typeof(a1)
    #print typeof(b1)
    #print " "
    
    #print typeof(a1.i)
    #print typeof(a1.s)
    #print typeof(b1.i)
    #print typeof(b1.s)
    
    print a1.i
    print a1.s
    print b1.i
    print b1.s
    

    Compilation:

    T
    T
    
    T
    T
    
    INTEGER
    SINGLE
    LONG
    DOUBLE
    

    Execution:

     1234
     1.234
     5678
     5.678
    

    It is as if in-house 'aT' and 'bT' are well-typed 'A.T' and 'B.T', but only namespace structure is filtered by 'typeof()'.

     

    Last edit: fxm (freebasic.net) 2015-04-12
  • dkl

    dkl - 2015-06-06

    This should be fixed in Git now: [e8871a]

     

    Related

    Commit: [e8871a]

  • dkl

    dkl - 2015-06-06
    • status: open --> closed
    • assigned_to: dkl
     

Log in to post a comment.

MongoDB Logo MongoDB