Feedback
Whole-number literals in Double or Decimal array literals stay Integer at runtime
- Status
- Fixed
- Fixed in
- v26.10.3
- Area
- compiler
- Source discussion
- https://forum.objo.dev/d/1354-some-feedback-from-building-chartview-web-support-and-a-few-language-notes
- Last updated
- 2026-10-20
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
A whole-number literal inside an array literal that is assigned to a Double or Decimal array stays an Integer at runtime. The assignment compiles because widening initialisers are accepted by design, but the elements are never converted, so calling a value-type method on an element fails at runtime. Example:
Var a() As Double = [12, 8, 0]
Print(a[0].IsNaN())
This raises a runtime error ("Only instances have methods") because a[0] is an Integer at runtime even though the array is declared As Double. Printing the element works (12), which masks the problem. The workaround is to force the literal type, for example 12.0 or value + 0.0.