fxm wrote:I performed similar tests from the current namespace (instead of the current type).
I performed similar tests with type names (instead of procedure names or variable names).
I performed similar tests with fbc 1.08 (instead of fbc 1.09) to check that (3) and (4) priority order is swapped.
Thank-you. Your examples are very helpful. The recent changes were to improve TYPES, but have had poor effects on NAMESPACEs.
Under the hood, there is only one mechanism for dealing with symbol lookups. I believe what I see emerging here is that symbols for TYPEs and NAMESPACEs can't be handled the same way.
1) For example, this hasn't changed in a NAMESPACE between fbc-1.08 and fbc-1.09, and I believe is incorrect - a current bug.
Code: Select all
namespace P
dim A as integer
end namespace
namespace C
using P
end namespace
? P.A
? C.A '' <<<--- this should not be allowed
2) Similar to 1) above but makes sense for TYPEs
Code: Select all
type P extends object
dim A as integer
end type
type C extends P
'' implicit 'using P'
end type
dim x as P, y as C
? x.A
? y.A '' <<--- OK
3) Here is another NAMESPACE example showing change from fbc-1.08
Code: Select all
dim shared A as integer = 1
namespace P
sub proc()
? A '' 1
end sub
namespace C1
dim A as integer = 2
sub proc()
? A '' 2
end sub
end namespace
namespace C2
using C1
sub proc()
? A '' 2 <<-- wrong for namespaces
end sub
end namespace
namespace C3
sub proc()
? A '' 1 <<-- correct for namespaces
end sub
end namespace
end namespace
P.proc()
P.C1.proc()
P.C2.proc()
P.C3.proc()
4) And similar to 3) above but for TYPES, showing the change from fbc-1.08
Code: Select all
dim shared A as integer = 1
type P extends object
declare sub proc()
end type
sub P.proc()
? A '' 1
end sub
type C1 extends P
'' implicit 'using P'
dim A as integer = 2
declare sub proc()
end type
sub C1.proc()
? A '' 2
end sub
type C2 extends C1
'' implicit 'using C1'
declare sub proc()
end type
sub C2.proc()
? A '' 2 <<--- correct for types
end sub
type C3 extends P
'' implicit 'using P'
declare sub proc()
end type
sub C3.proc()
? A '' 1 <<--- still bugged for types
end sub
dim w as P, x as C1, y as C2, z as C3
w.proc()
x.proc()
y.proc()
z.proc()
So, what this means is I can't just make improvements to our 'lookup' function. I believe the symbol table needs some information added about how the symbol was imported. Well, the information is there, it's just not in a structure that is efficient to work with at the moment.