Closed
Description
Normally i ask on the dart official discord server. Comments in the code are describing what is happening and why something else could happen in some cases, what i see, and what in my opinion (limited knowledge) would cause the "extension type" to be perfect.
Please take note that there is here below a new type Int defined, starting from a big letter I (not "int"). Also there may be similar situations like these below, but this is enough for now.
extension type Int(int i) implements int {
Int operator +(int other) {
return Int(i + other);
}
}
void main() {
int a = 2;
Int b = Int(8); // coulndn't Int b = 8? and silently cast as Int?
b = b + a; // wrong, but Int + operator overriden returns Int
b = a + b; // wrong, because a is int, but couldn't it be silently cast to Int?
a = a + b; // good as expected.
print(b + a); // ok, somewhere toString is called for sure.
print(b + b);
print(a + b);
}
So, do you think that at least b = b + a shouldn't be marked as error in my VScode? I imagined a reason why it should, but i don't know. Any opinions?