Title: A division right after `++` or `--` in a template is read as a regular expression · Issue #71509 · angular/angular · GitHub
Open Graph Title: A division right after `++` or `--` in a template is read as a regular expression · Issue #71509 · angular/angular
X Title: A division right after `++` or `--` in a template is read as a regular expression · Issue #71509 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description Since templates support ++ and -- (#70816), a slash that follows them is read as the start of a regular expression literal instead of a ...
Open Graph Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description Since templates support ++ and -- (#70816), a slash that follows them is read as the start of a ...
X Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description Since templates support ++ and -- (#70816), a slash that follows them is read as the start of a ...
Opengraph URL: https://github.com/angular/angular/issues/71509
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A division right after `++` or `--` in a template is read as a regular expression","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncompiler\n\n### Is this a regression?\n\nNo\n\n### Description\n\nSince templates support `++` and `--` (#70816), a slash that follows them is read as the start of a regular expression literal instead of a division:\n\n```html\n\u003cbutton (click)=\"half = count++ / 2\">Half, then increment\u003c/button>\n```\n\n```\nParser Error: Unexpected token 'Lexer Error: Unterminated regular expression at column 18 in expression [half = count++ / 2]' at column 19 in [half = count++ / 2]\n```\n\nWith a second slash it gets stranger: in `total = count-- / size / 2`, ` size ` becomes the body of a regex and the parser reports `Unexpected token ' size '`. Host listeners behave the same way.\n\nThis is valid JavaScript, and `count++ * 2` works fine. The lexer's `isStartOfRegex` treats any operator before a `/` as the start of a regex. That's right after `=` or `&&`, but after `++` or `--` a slash can only be a division. Wrapping the update in parentheses works around it: `(count++) / 2`.\n\n#71510 fixes it. Only the 22.3.0-next releases are affected, since 22.2.x doesn't have the update operators.\n\n### Please provide a link to a minimal reproduction of the bug\n\nNo hosted reproduction, but this is enough:\n\n```ts\nimport {Component} from '@angular/core';\nimport {bootstrapApplication} from '@angular/platform-browser';\n\n@Component({\n selector: 'app-root',\n template: `\n \u003cp>Count: {{ count }}\u003c/p>\n \u003cbutton (click)=\"half = count++ / 2\">Half, then increment\u003c/button>\n \u003cp>Half: {{ half }}\u003c/p>\n `,\n})\nexport class App {\n count = 10;\n half: number | null = null;\n}\n\nbootstrapApplication(App);\n```\n\n### Please provide the exception or error you saw\n\n```true\nNG5002: Parser Error: Unexpected token 'Lexer Error: Unterminated regular expression at column 18 in expression [half = count++ / 2]' at column 19 in [half = count++ / 2]\nNG5002: Parser Error: Lexer Error: Unterminated regular expression at column 18 in expression [half = count++ / 2] at the end of the expression [half = count++ / 2]\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\n@angular/compiler 22.3.0-next.2, and main (d0b33ad25f).\n```\n\n### Anything else?\n\n_No response_\n","author":{"url":"https://github.com/aminesbdev","@type":"Person","name":"aminesbdev"},"datePublished":"2026-10-21T07:39:32Z","url":"https://github.com/angular/angular/issues/71509"}
| 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:7b924fe9-37cb-7aba-f1b7-f0268f4ddce5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3B8:2C4BED:13F89DD:196CACD:6B01282B |
| html-safe-nonce | fa0ecf897ea62de83e017db45982e8d2060bbcfac01074e2743ae3a14ca0ec41 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0I4OjJDNEJFRDoxM0Y4OUREOjE5NkNBQ0Q6NkIwMTI4MkIiLCJ2aXNpdG9yX2lkIjoiMTIzNzExMzg1NjIyNDk5NTM3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5aca27dffa2b2132c79699aac997e3e136e00ae3e04177c406879d5c839920e8 |
| hovercard-subject-tag | issue:5956411078 |
| 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/71509/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f333f445b03299cd440ebc0193c1317e5f52318696a24e9a60a4b5181e54934a/angular/angular/issues/71509 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f333f445b03299cd440ebc0193c1317e5f52318696a24e9a60a4b5181e54934a/angular/angular/issues/71509 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description Since templates support ++ and -- (#70816), a slash that follows them is read as the start of a ... |
| 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