{"action":"opened","issue":{"url":"https://api.github.com/repos/fasterthanlime/rock/issues/869","labels_url":"https://api.github.com/repos/fasterthanlime/rock/issues/869/labels{/name}","comments_url":"https://api.github.com/repos/fasterthanlime/rock/issues/869/comments","events_url":"https://api.github.com/repos/fasterthanlime/rock/issues/869/events","html_url":"https://github.com/fasterthanlime/rock/issues/869","id":60790253,"number":869,"title":"Assignment operators ","user":{"login":"davidhesselbom","id":4319680,"avatar_url":"https://avatars.githubusercontent.com/u/4319680?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhesselbom","html_url":"https://github.com/davidhesselbom","followers_url":"https://api.github.com/users/davidhesselbom/followers","following_url":"https://api.github.com/users/davidhesselbom/following{/other_user}","gists_url":"https://api.github.com/users/davidhesselbom/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhesselbom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhesselbom/subscriptions","organizations_url":"https://api.github.com/users/davidhesselbom/orgs","repos_url":"https://api.github.com/users/davidhesselbom/repos","events_url":"https://api.github.com/users/davidhesselbom/events{/privacy}","received_events_url":"https://api.github.com/users/davidhesselbom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-12T09:18:37Z","updated_at":"2015-03-12T09:18:37Z","closed_at":null,"body":"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](https://github.com/fasterthanlime/rock/blob/master/source/rock/middle/BinaryOp.ooc)), `%=` 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.\r\n\r\nThe source of one of these problems seems to be the `%` operator in [BinaryOp](https://github.com/fasterthanlime/rock/blob/master/source/rock/middle/BinaryOp.ooc), which offsets the rest of the operators in the list. 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.\r\n\r\n```ooc\r\nFoo: class {\r\n\tvalue: Int\r\n\tinit: func(=value)\r\n}\r\noperator + (left, right: Foo) -> Foo {\r\n\t\"+\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator - (left, right: Foo) -> Foo {\r\n\t\"-\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator * (left, right: Foo) -> Foo {\r\n\t\"*\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator ** (left, right: Foo) -> Foo {\r\n\t\"**\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator / (left, right: Foo) -> Foo {\r\n\t\"/\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator % (left, right: Foo) -> Foo {\r\n\t\"%\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator >> (left, right: Foo) -> Foo {\r\n\t\">>\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator << (left, right: Foo) -> Foo {\r\n\t\"<<\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator | (left, right: Foo) -> Foo {\r\n\t\"|\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator ^ (left, right: Foo) -> Foo {\r\n\t\"^\" println()\r\n\tFoo new(left value + right value)\r\n}\r\noperator & (left, right: Foo) -> Foo {\r\n\t\"&\" println()\r\n\tFoo new(left value + right value)\r\n}\r\n\r\nfoo := Foo new(1)\r\n\r\nfoo = foo + Foo new(2) // +\r\nfoo += Foo new(3) // +\r\n\r\nfoo = foo - Foo new(2) // -\r\nfoo -= Foo new(3) // -\r\n\r\nfoo = foo * Foo new(2) // *\r\nfoo *= Foo new(3) // *\r\n\r\nfoo = foo ** Foo new(2) // **\r\nfoo **= Foo new(3) // **\r\n\r\nfoo = foo / Foo new(2) // /\r\nfoo /= Foo new(3) // /\r\n\r\nfoo = foo % Foo new(2) // %\r\n//foo %= Foo new(3)\r\n// error Expected include, import, statement or declaration\r\n\r\nfoo = foo >> Foo new(2) // >>\r\n//foo >>= Foo new(3)\r\n// error Missing right operand for '>' operator!\r\n\r\nfoo = foo << Foo new(2) // <<\r\n//foo <<= Foo new(3) \r\n// error Missing right operand for '<' operator!\r\n\r\nfoo = foo | Foo new(2) // |\r\nfoo |= Foo new(3) // <<, but expected |. If << is not implemented,\r\n// error Invalid use of operator << between operands of type Foo and Foo\r\n\r\nfoo = foo ^ Foo new(2) // ^\r\nfoo ^= Foo new(3) // |, but expected ^. If | is not implemented,\r\n// error Invalid use of operator | between operands of type Foo and Foo\r\n\r\nfoo = foo & Foo new(2) // & \r\nfoo &= Foo new(3) // ^, but expected &. If ^ is not implemented,\r\n// error Invalid use of operator ^ between operands of type Foo and Foo\r\n\r\n```"}}