Feedback
Var array declarations accept initialisers of unrelated element types
- Status
- Fixed
- Fixed in
- v26.10.2
- Area
- compiler
- Source discussion
- -
- Last updated
- 2026-10-12
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
A Var declaration with an explicit array type accepts an initial value of any other array type without checking the element types, so Var animals() As Animal = rocks compiles even when rocks is an array of a completely unrelated class. Calls on the elements through the declared type also compile and then fail at runtime. Assigning the same value through a plain assignment statement, a parameter, or a function return is correctly rejected, so the declaration path alone opens the hole.