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
Assignment operators #869
Comments
It seems that
If parser fails to match ">>" then it will try ">", here MORETHAN matches. We should change these lines to:
|
Incorrect function call is caused by
but we have an extra |
comes from ooc-lang#869
I just noticed now that if both unary and binary Also, the error message reports the line above the one where the operator is implemented, so Point2D: class {
x, y: Float
init: func(=x, =y)
operator - -> This { This new(-this x, -this y) }
operator - (other: This) -> This { This new(this x - other x, this y - other y) }
}
p := Point2D new(1.0f, 1.0f)
p2 := Point2D new(2.0f, 2.0f)
p -= p2 gives me
but Point2D: class {
x, y: Float
init: func(=x, =y)
operator - (other: This) -> This { This new(this x - other x, this y - other y) }
operator - -> This { This new(-this x, -this y) }
}
p := Point2D new(1.0f, 1.0f)
p2 := Point2D new(2.0f, 2.0f)
p -= p2 (all I did was swap lines 4 and 5) gives me
In either case, p := Point2D new(1.0f, 1.0f)
p2 := Point2D new(2.0f, 2.0f)
p = p - p2 works just fine. |
Overriding some of the assignment operators doesn't work. It works for
+= -= *= **= /=
, but for|= ^= &=
, rock picks the wrong operator (the preceding one in the list of operators in BinaryOp),%=
doesn't work at all and>>= <<=
seem to be mistaken for> <
. The code below demonstrates the problem. Comments show the output for each line, and expected output where applicable.The source of one of these problems seems to be the
%
operator in BinaryOp, which offsets the rest of the operators in the list - this is why the operators above%
in the list work as expected, but the rest don't. If the%
operator were to be moved down the list to very end of it, or if a%=
operator was made possible, that would probably solve the problem for|= ^= &=
.>>= <<=
is, perhaps, a different problem.The text was updated successfully, but these errors were encountered: