Thanks, this is a real compiler bug.
The problem was that namespaced types were being registered with a global short-name alias. So Einhugur.Test.MyClass also became visible as MyClass, even when Einhugur.Test had not been imported. That made this lookup wrong:
Var s As Einhugur.Test.MyClass = New MyClass()
New MyClass() should not search every namespace in the project. It should resolve by scope:
- current namespace/module chain
- active
Imports
- root/global namespace
So after the fix:
Var s As Einhugur.Test.MyClass = New MyClass()
will resolve MyClass to the root-level MyClass if one exists, and then correctly report that it cannot assign MyClass to Einhugur.Test.MyClass. If no root MyClass exists, it reports Unknown type 'MyClass'.
The valid forms are now:
Var s As Einhugur.Test.MyClass = New Einhugur.Test.MyClass()
or:
Import Einhugur.Test
Var s As MyClass = New MyClass()
I also tightened the runtime emitter so imported short names compile to the correct fully qualified runtime type, instead of relying on hidden global aliases.
This will be in the next release: https://feedback.objo.dev/bug/508