Title: `a--b` in a template fails with "Bindings cannot contain assignments" since 22.3.0-next.0 · Issue #71409 · angular/angular · GitHub
Open Graph Title: `a--b` in a template fails with "Bindings cannot contain assignments" since 22.3.0-next.0 · Issue #71409 · angular/angular
X Title: `a--b` in a template fails with "Bindings cannot contain assignments" since 22.3.0-next.0 · Issue #71409 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description Up to 22.2, a--b in a template meant a - -b, and a++b meant a + +b. Now that ++ and -- are update operators (#70816), a--b is read like...
Open Graph Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description Up to 22.2, a--b in a template meant a - -b, and a++b meant a + +b. Now that ++ and -- are upda...
X Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description Up to 22.2, a--b in a template meant a - -b, and a++b meant a + +b. Now that ++ and -- are upda...
Opengraph URL: https://github.com/angular/angular/issues/71409
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`a--b` in a template fails with \"Bindings cannot contain assignments\" since 22.3.0-next.0","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncompiler\n\n### Is this a regression?\n\nYes\n\n### Description\n\nUp to 22.2, `a--b` in a template meant `a - -b`, and `a++b` meant `a + +b`. Now that `++` and `--` are update operators (#70816), `a--b` is read like in JavaScript, as `a--` followed by `b`. I think that's fine, it isn't valid JavaScript either. What's confusing is the error you get when a template still has it:\n\n```html\n\u003cp>{{ a--b }}\u003c/p>\n```\n\n```\nParser Error: Bindings cannot contain assignments at column 5 in [ a--b ]\n```\n\nThere's no assignment in that template, so I went looking for one before realizing the `--` was the problem. In an event binding, `(click)=\"x = a--b\"` gives `Unexpected token 'b'`, which is closer, but it still doesn't say why. `[title]=\"a--1\"` and `{{ a++b }}` fail the same way.\n\nI opened #71410 to keep these as errors but say what to write instead:\n\n```\nUnexpected token 'b' after the '--' decrement operator. To subtract '-b', write '- -b'\n```\n\n### Please provide a link to a minimal reproduction of the bug\n\nNo hosted reproduction, but this is all it takes:\n\n```ts\nimport {Component} from '@angular/core';\nimport {bootstrapApplication} from '@angular/platform-browser';\n\n@Component({\n selector: 'app-root',\n template: `\u003cp>{{ a--b }}\u003c/p>`,\n})\nexport class App {\n a = 5;\n b = 3;\n}\n\nbootstrapApplication(App);\n```\n\n22.2.2 renders `8`. On main it doesn't compile.\n\n### Please provide the exception or error you saw\n\n```true\nParser Error: Bindings cannot contain assignments at column 5 in [ a--b ] in ng:///App/template.html@0:3\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nReproduced on the main branch of angular/angular (ce30bb0889). 22.2.2 compiles the same template.\n```\n\n### Anything else?\n\nThere's a related change that can't show up as an error: `(click)=\"x = --a\"` used to set `x` to `a` (two unary minuses), and now it decrements `a` first. That's what JavaScript does, so I left it alone, but it might be worth a line in the release notes for the new operators.\n","author":{"url":"https://github.com/aminesbdev","@type":"Person","name":"aminesbdev"},"datePublished":"2026-10-17T11:03:52Z","url":"https://github.com/angular/angular/issues/71409"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b8698d4d-e813-8fb3-a90b-970cbcd32cf9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB7C:DB09F:131FA33:1869764:6B012814 |
| html-safe-nonce | 491e750d06f2b6d7c89cbf3fb4a23e7fd228af8f76bd139877c7c1f8540eab8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjdDOkRCMDlGOjEzMUZBMzM6MTg2OTc2NDo2QjAxMjgxNCIsInZpc2l0b3JfaWQiOiI3NjE0MzQ2OTgwMjYwNjUzMDc2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7c084d6ba5eae5a45a59a754f26fd654b4fdc06615c963360975afddda0cfcd1 |
| hovercard-subject-tag | issue:5897681783 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/71409/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c32e173f9d21624bb77b8f6c40e5fe9d708f66630530129aee5bc892677ca616/angular/angular/issues/71409 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c32e173f9d21624bb77b8f6c40e5fe9d708f66630530129aee5bc892677ca616/angular/angular/issues/71409 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description Up to 22.2, a--b in a template meant a - -b, and a++b meant a + +b. Now that ++ and -- are upda... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aminesbdev |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width