Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloading operators shadows the built-in ones #2

Open
kyouko-taiga opened this issue Oct 23, 2018 · 0 comments
Open

Overloading operators shadows the built-in ones #2

kyouko-taiga opened this issue Oct 23, 2018 · 0 comments
Labels
bug Something isn't working

Comments

@kyouko-taiga
Copy link
Owner

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.

@kyouko-taiga kyouko-taiga added the bug Something isn't working label Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant