Clarify assignment-expression diagnostic in comprehension iterables - #11542
Clarify assignment-expression diagnostic in comprehension iterables#11542Shinzzyak wants to merge 1 commit into
Conversation
|
|
@microsoft-github-policy-service agree |
|
🔒 Automated review in progress — @rchiodo is auto-reviewing this PR. |
| assert.strictEqual( | ||
| errors[0].message, | ||
| 'Assignment expression cannot be used in a comprehension iterable expression' | ||
| ); |
There was a problem hiding this comment.
📍 packages/pyright-internal/src/tests/parser.test.ts:203
The only new test uses a nested comprehension, while the issue's headline scenario is the direct iterable [x for x in (z := range(10))]. Add a second assertion on that canonical (parenthesized, still-rejected) form so the regression is tied to #11514's primary case and documents that parentheses do not help.
|
Clean, well-scoped fix. Consider also asserting the issue's canonical direct-iterable form to lock in the primary regression; otherwise looks good to merge. |
rchiodo
left a comment
There was a problem hiding this comment.
Approved via Review Center.
rchiodo
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Fixes #11514.
Use the grammar-specific diagnostic when an assignment expression appears in a comprehension iterable, where adding parentheses cannot make it valid.
Tests:
npm run build;npm run test:norebuild -- --runInBand parser.test.ts.