{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/prometheus/pulls/comments/67670841","id":67670841,"diff_hunk":"@@ -500,7 +500,8 @@ func (p *parser) expr() Expr {\n }\n \n func (p *parser) balance(lhs Expr, op itemType, rhs Expr, vecMatching *VectorMatching, returnBool bool) *BinaryExpr {\n-\tif lhsBE, ok := lhs.(*BinaryExpr); ok && lhsBE.Op.precedence() < op.precedence() {\n+\tif lhsBE, ok := lhs.(*BinaryExpr); (ok && lhsBE.Op.precedence() < op.precedence()) ||\n+\t\t(ok && lhsBE.Op.precedence() == op.precedence() && lhsBE.Op == itemPOW && op == itemPOW) {","path":"promql/parse.go","position":6,"original_position":6,"commit_id":"433c93ac858902e82e19a024e5e3a0c052c5294f","original_commit_id":"433c93ac858902e82e19a024e5e3a0c052c5294f","user":{"login":"fabxc","id":4948210,"avatar_url":"https://avatars.githubusercontent.com/u/4948210?v=3","gravatar_id":"","url":"https://api.github.com/users/fabxc","html_url":"https://github.com/fabxc","followers_url":"https://api.github.com/users/fabxc/followers","following_url":"https://api.github.com/users/fabxc/following{/other_user}","gists_url":"https://api.github.com/users/fabxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fabxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabxc/subscriptions","organizations_url":"https://api.github.com/users/fabxc/orgs","repos_url":"https://api.github.com/users/fabxc/repos","events_url":"https://api.github.com/users/fabxc/events{/privacy}","received_events_url":"https://api.github.com/users/fabxc/received_events","type":"User","site_admin":false},"body":"Would indeed be good to encapsulate associativity logic here for future clarity. We could define another method similar to `precedence()`; `isRightAssociative()` seems simple enough.\r\n\r\nTo make the code more self-explanatory we could structure this condition something like:\r\n\r\n```go\r\nlhsBE, ok := lhs.(*BinaryExpr)\r\nprecd := lhsBe.Op.precedence() - op.precedence()\r\n// Relies on the invariant that no operators with the same precedence level can have different associativity.\r\nif ok && (precd < 0 || precd == 0 && op.isRightAssociative()) {\r\n    // ...\r\n}\r\n```\r\n\r\nDoes that make sense?\r\n","created_at":"2016-06-20T10:56:06Z","updated_at":"2016-06-20T10:56:06Z","html_url":"https://github.com/prometheus/prometheus/pull/1687#discussion_r67670841","pull_request_url":"https://api.github.com/repos/prometheus/prometheus/pulls/1687","_links":{"self":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/comments/67670841"},"html":{"href":"https://github.com/prometheus/prometheus/pull/1687#discussion_r67670841"},"pull_request":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/1687"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/prometheus/pulls/1687","id":71822344,"html_url":"https://github.com/prometheus/prometheus/pull/1687","diff_url":"https://github.com/prometheus/prometheus/pull/1687.diff","patch_url":"https://github.com/prometheus/prometheus/pull/1687.patch","issue_url":"https://api.github.com/repos/prometheus/prometheus/issues/1687","number":1687,"state":"open","locked":false,"title":"Added power binop","user":{"login":"royels","id":4454340,"avatar_url":"https://avatars.githubusercontent.com/u/4454340?v=3","gravatar_id":"","url":"https://api.github.com/users/royels","html_url":"https://github.com/royels","followers_url":"https://api.github.com/users/royels/followers","following_url":"https://api.github.com/users/royels/following{/other_user}","gists_url":"https://api.github.com/users/royels/gists{/gist_id}","starred_url":"https://api.github.com/users/royels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/royels/subscriptions","organizations_url":"https://api.github.com/users/royels/orgs","repos_url":"https://api.github.com/users/royels/repos","events_url":"https://api.github.com/users/royels/events{/privacy}","received_events_url":"https://api.github.com/users/royels/received_events","type":"User","site_admin":false},"body":"Addresses issue #1629 \r\n@brian-brazil I thought I’d have a go at it, no pun intended. I used the `^` syntax.\r\n","created_at":"2016-05-29T09:16:29Z","updated_at":"2016-06-20T10:56:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40138e43a24ece9c92416a97b99aa7412618a2b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/prometheus/pulls/1687/commits","review_comments_url":"https://api.github.com/repos/prometheus/prometheus/pulls/1687/comments","review_comment_url":"https://api.github.com/repos/prometheus/prometheus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/prometheus/issues/1687/comments","statuses_url":"https://api.github.com/repos/prometheus/prometheus/statuses/433c93ac858902e82e19a024e5e3a0c052c5294f","head":{"label":"royels:issue-1629","ref":"issue-1629","sha":"433c93ac858902e82e19a024e5e3a0c052c5294f","user":{"login":"royels","id":4454340,"avatar_url":"https://avatars.githubusercontent.com/u/4454340?v=3","gravatar_id":"","url":"https://api.github.com/users/royels","html_url":"https://github.com/royels","followers_url":"https://api.github.com/users/royels/followers","following_url":"https://api.github.com/users/royels/following{/other_user}","gists_url":"https://api.github.com/users/royels/gists{/gist_id}","starred_url":"https://api.github.com/users/royels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/royels/subscriptions","organizations_url":"https://api.github.com/users/royels/orgs","repos_url":"https://api.github.com/users/royels/repos","events_url":"https://api.github.com/users/royels/events{/privacy}","received_events_url":"https://api.github.com/users/royels/received_events","type":"User","site_admin":false},"repo":{"id":59934797,"name":"prometheus","full_name":"royels/prometheus","owner":{"login":"royels","id":4454340,"avatar_url":"https://avatars.githubusercontent.com/u/4454340?v=3","gravatar_id":"","url":"https://api.github.com/users/royels","html_url":"https://github.com/royels","followers_url":"https://api.github.com/users/royels/followers","following_url":"https://api.github.com/users/royels/following{/other_user}","gists_url":"https://api.github.com/users/royels/gists{/gist_id}","starred_url":"https://api.github.com/users/royels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/royels/subscriptions","organizations_url":"https://api.github.com/users/royels/orgs","repos_url":"https://api.github.com/users/royels/repos","events_url":"https://api.github.com/users/royels/events{/privacy}","received_events_url":"https://api.github.com/users/royels/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/royels/prometheus","description":"The Prometheus monitoring system and time series database.","fork":true,"url":"https://api.github.com/repos/royels/prometheus","forks_url":"https://api.github.com/repos/royels/prometheus/forks","keys_url":"https://api.github.com/repos/royels/prometheus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/royels/prometheus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/royels/prometheus/teams","hooks_url":"https://api.github.com/repos/royels/prometheus/hooks","issue_events_url":"https://api.github.com/repos/royels/prometheus/issues/events{/number}","events_url":"https://api.github.com/repos/royels/prometheus/events","assignees_url":"https://api.github.com/repos/royels/prometheus/assignees{/user}","branches_url":"https://api.github.com/repos/royels/prometheus/branches{/branch}","tags_url":"https://api.github.com/repos/royels/prometheus/tags","blobs_url":"https://api.github.com/repos/royels/prometheus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/royels/prometheus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/royels/prometheus/git/refs{/sha}","trees_url":"https://api.github.com/repos/royels/prometheus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/royels/prometheus/statuses/{sha}","languages_url":"https://api.github.com/repos/royels/prometheus/languages","stargazers_url":"https://api.github.com/repos/royels/prometheus/stargazers","contributors_url":"https://api.github.com/repos/royels/prometheus/contributors","subscribers_url":"https://api.github.com/repos/royels/prometheus/subscribers","subscription_url":"https://api.github.com/repos/royels/prometheus/subscription","commits_url":"https://api.github.com/repos/royels/prometheus/commits{/sha}","git_commits_url":"https://api.github.com/repos/royels/prometheus/git/commits{/sha}","comments_url":"https://api.github.com/repos/royels/prometheus/comments{/number}","issue_comment_url":"https://api.github.com/repos/royels/prometheus/issues/comments{/number}","contents_url":"https://api.github.com/repos/royels/prometheus/contents/{+path}","compare_url":"https://api.github.com/repos/royels/prometheus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/royels/prometheus/merges","archive_url":"https://api.github.com/repos/royels/prometheus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/royels/prometheus/downloads","issues_url":"https://api.github.com/repos/royels/prometheus/issues{/number}","pulls_url":"https://api.github.com/repos/royels/prometheus/pulls{/number}","milestones_url":"https://api.github.com/repos/royels/prometheus/milestones{/number}","notifications_url":"https://api.github.com/repos/royels/prometheus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/royels/prometheus/labels{/name}","releases_url":"https://api.github.com/repos/royels/prometheus/releases{/id}","deployments_url":"https://api.github.com/repos/royels/prometheus/deployments","created_at":"2016-05-29T09:04:23Z","updated_at":"2016-05-29T09:04:25Z","pushed_at":"2016-06-20T05:31:43Z","git_url":"git://github.com/royels/prometheus.git","ssh_url":"git@github.com:royels/prometheus.git","clone_url":"https://github.com/royels/prometheus.git","svn_url":"https://github.com/royels/prometheus","homepage":"https://prometheus.io/","size":10691,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"beecbe3d2f0d39035d050020c4a981b1529367ce","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":6838921,"name":"prometheus","full_name":"prometheus/prometheus","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/prometheus","description":"The Prometheus monitoring system and time series database.","fork":false,"url":"https://api.github.com/repos/prometheus/prometheus","forks_url":"https://api.github.com/repos/prometheus/prometheus/forks","keys_url":"https://api.github.com/repos/prometheus/prometheus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/prometheus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/prometheus/teams","hooks_url":"https://api.github.com/repos/prometheus/prometheus/hooks","issue_events_url":"https://api.github.com/repos/prometheus/prometheus/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/prometheus/events","assignees_url":"https://api.github.com/repos/prometheus/prometheus/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/prometheus/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/prometheus/tags","blobs_url":"https://api.github.com/repos/prometheus/prometheus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/prometheus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/prometheus/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/prometheus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/prometheus/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/prometheus/languages","stargazers_url":"https://api.github.com/repos/prometheus/prometheus/stargazers","contributors_url":"https://api.github.com/repos/prometheus/prometheus/contributors","subscribers_url":"https://api.github.com/repos/prometheus/prometheus/subscribers","subscription_url":"https://api.github.com/repos/prometheus/prometheus/subscription","commits_url":"https://api.github.com/repos/prometheus/prometheus/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/prometheus/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/prometheus/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/prometheus/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/prometheus/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/prometheus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/prometheus/merges","archive_url":"https://api.github.com/repos/prometheus/prometheus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/prometheus/downloads","issues_url":"https://api.github.com/repos/prometheus/prometheus/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/prometheus/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/prometheus/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/prometheus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/prometheus/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/prometheus/releases{/id}","deployments_url":"https://api.github.com/repos/prometheus/prometheus/deployments","created_at":"2012-11-24T11:14:12Z","updated_at":"2016-06-20T08:52:07Z","pushed_at":"2016-06-20T05:31:43Z","git_url":"git://github.com/prometheus/prometheus.git","ssh_url":"git@github.com:prometheus/prometheus.git","clone_url":"https://github.com/prometheus/prometheus.git","svn_url":"https://github.com/prometheus/prometheus","homepage":"https://prometheus.io/","size":15045,"stargazers_count":5070,"watchers_count":5070,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":431,"mirror_url":null,"open_issues_count":167,"forks":431,"open_issues":167,"watchers":5070,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/1687"},"html":{"href":"https://github.com/prometheus/prometheus/pull/1687"},"issue":{"href":"https://api.github.com/repos/prometheus/prometheus/issues/1687"},"comments":{"href":"https://api.github.com/repos/prometheus/prometheus/issues/1687/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/1687/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/1687/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/prometheus/statuses/433c93ac858902e82e19a024e5e3a0c052c5294f"}}}}
{"actor":{"display_login":"fabxc"}}