toit
toit copied to clipboard
Error message for bad types in number operations should be improved
main:
x /any := "str"
print 3 + x
yields
Class 'string' does not have any method 'add_from_small_integer_'.
0: SmallInteger_.+ <sdk>/core/numbers.toit:966:20
1: main bad.toit:3:11
2: __entry__.<lambda> <sdk>/core/entry.toit:48:20
Would be nice to have a type-mismatch error instead.
Since we are intercepting operations anyway, we only reach the methods when the shortcut fails. As such we should probably just add type annotations to the methods.