Hi Bjorn,
You’re right. This is a compiler bug, not an invalid use of namespaces.
The intended behaviour is that a class Class1 with namespace Einhugur should be usable as:
Var c As Einhugur.Class1 = New Einhugur.Class1
and also, with an import:
Import Einhugur
Var c As New Class1
Those forms do work. The broken case was specifically the shorthand form:
Var c As New Einhugur.Class1
The parser was correctly building the New expression as Einhugur.Class1, but it was storing the variable’s declared type as only the first identifier, Einhugur. The type checker then tried to resolve Einhugur as a type and reported Unknown type 'Einhugur'.
I’ve fixed this so As New now preserves the full dotted type name. I also added coverage for:
- qualified
As New with namespaces
- imported namespace short names
- duplicate class short names in different namespaces
- nested namespace paths
- local namespace imports
- module-qualified nested classes
- Studio source-item Namespace metadata, including runtime execution
The fix is in for the next release: https://feedback.objo.dev/bug/539
Until the next build is available, the workaround is to avoid the qualified As New shorthand and use either:
Var c As Einhugur.Class1 = New Einhugur.Class1
or:
Import Einhugur
Var c As New Class1
Thanks for raising it. This was a real gap in my internal namespace test coverage.