Thanks, this was a useful report. There were two separate things going on here.
First, this syntax:
_upperToLowerDictionary = Dictionary(Of Integer, Integer)
is not a dictionary construction expression. Dictionary(Of Integer, Integer) is a type name, not a value. It is valid in places where the grammar expects a type, for example:
Var d As Dictionary(Of Integer, Integer)
or, from the next build ( 😉 ):
Var d As New Dictionary(Of Integer, Integer)
Since your property is already declared as Dictionary(Of Integer, Integer), the shortest correct assignment is:
_upperToLowerDictionary = {}
The empty dictionary literal gets its key/value types from the typed assignment target.
This syntax is also not valid Objo:
_upperToLowerDictionary = Dictionary(Of Integer, Integer) = {}
That is effectively trying to put a type annotation into the right-hand side of an assignment. Objo does not have inline typed dictionary literals in that form.
That said, the compiler diagnostics were definitely poor. In particular:
Cannot assign Dictionary to variable of type 'Dictionary' was hiding the generic arguments, making the error look contradictory.
Expected '(' after generic type arguments was too parser-internal for this case.
- Error recovery could put the marker later than the actual bad assignment line.
I’ve fixed these for the next build. The compiler now recognises this specific mistake and reports that Dictionary(Of K, V) is a type, not a value, with a suggestion to use {} in a typed context or New Dictionary(Of K, V). Assignment mismatch errors also now preserve the full parameterised type names.
I’ve also added support for:
Var d As New Dictionary(Of Integer, String)
and:
Var d As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String)
Both create an empty dictionary. Constructor arguments are not supported for Dictionary at the moment; use Reserve(capacity) if you want to reserve storage.
So the original workaround with a temporary variable will no longer be necessary.
Tracked: https://feedback.objo.dev/bug/553