You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Overloading a built-in operator (e.g. +) in a user module shadows the built-in definitions of the same operator, making it impossible to manipulate built-in values.
Here's a minimal example:
type Point :: #point(x: Int, y: Int)
func + (_ lhs: Point, _ rhs: Point) -> Point ::
#point(x: lhs.x + rhs.x, y: lhs.y + rhs.y)
The above code will produce a type error complaining that #point(x: Int, y: Int) does not match type Int, suggesting that the operator + between integers is no longer considered by the type solver. Further evidences can be found by observing the type constraints generated by the above program, which do not feature any disjunction.
The text was updated successfully, but these errors were encountered:
Overloading a built-in operator (e.g.
+
) in a user module shadows the built-in definitions of the same operator, making it impossible to manipulate built-in values.Here's a minimal example:
The above code will produce a type error complaining that
#point(x: Int, y: Int)
does not match typeInt
, suggesting that the operator+
between integers is no longer considered by the type solver. Further evidences can be found by observing the type constraints generated by the above program, which do not feature any disjunction.The text was updated successfully, but these errors were encountered: