GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add logical assignment operator by Kingwl · Pull Request #37727 · microsoft/TypeScript Conversation
|
|
Resolved |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| function foo2 (f?: (a: number) => void) { | ||
| f ||= (a => a) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Great test!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
😉
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (thing &&= thing.original) { | ||
| console.log(thing.name); | ||
| ~~~~~ | ||
| !!! error TS2532: Object is possibly 'undefined'. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Glad the test caught this - that was part of my intent when I wrote it. As you probably know, this needs to be fixed because thing.original should be defined. Let Anders Hejlsberg (@ahejlsberg) or Ron Buckton (@rbuckton) know if you need help with that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I spent all afternoon And evening in this one😂
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the code can be hard to get through, and I've honestly never wired up the CFG. Also, binary expressions recently changed to use a "trampolining" approach to avoid stack overflows on deep traversals. You can ask Wesley Wigham (@weswigham) about that.
If you want to play around to see if you can get it working, I'll provide a few tips and Wesley Wigham (@weswigham) and Anders Hejlsberg (@ahejlsberg) can weigh in case I'm totally off.
First take a look at some of the logic at
TypeScript/src/compiler/binder.ts
Line 1418 in b58a29b
| const preRightLabel = createBranchLabel(); |
and
TypeScript/src/compiler/binder.ts
Line 1513 in b58a29b
| if (operator === SyntaxKind.AmpersandAmpersandToken || operator === SyntaxKind.BarBarToken || operator === SyntaxKind.QuestionQuestionToken) { |
The binder needs to create branch labels for these new compound assignment operators (similar to in bindLogicalExpression) while creating at least one flow node that's considered an assignment after the expression (as in bindAssignmentTargetFlow). At a glance, I think that a lot of the logic can be reused and the changes can be added around here
Eventually in getTypeAtFlowNode in the type-checker, you need to try to find a way to combine the logic when flags & FlowFlags.Assignment and flags & FlowFlags.Label both apply. To start, I'd just get something working, then worry about how to share the code.
Feel free to ask some questions if you need help. If you'd prefer, I'm also sure we could send a PR if you'd like, but it's up to you.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| || token === SyntaxKind.ExclamationToken; | ||
| } | ||
|
|
||
| export function isLogicalAssignmentOperator(token: SyntaxKind): boolean { |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Consider isShortCircuitingAssignmentOperator or isLogicalOrCoalescingAssignmentOperator
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return 14; | ||
| case SyntaxKind.AsteriskAsteriskToken: | ||
| return 15; | ||
| case SyntaxKind.BarBarEqualsToken: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This section doesn't seem to cover any of the assignment or compound assignment operators. I'd get clarity from whoever originally wrote this function whether this should be here, because I think these 3 cases don't belong here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it seems to be caught by getOperatorPrecedence above.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
2f6dfd7 to
1c92781
Compare
|
It seems works, but i don't know why.🤷🏻♂️ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
TypeScript Bot (@typescript-bot) pack this |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the tarball bundle task on this PR at 1c92781. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Current CFG is the same as downlevel result |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
TypeScript Bot (@typescript-bot) pack this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Wenlu Wang (@Kingwl), I've started to run the tarball bundle task on this PR at a6e0086. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey Wenlu Wang (@Kingwl), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
17b858c to
1ed6a3e
Compare
|
TypeScript Bot (@typescript-bot) pack this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Wenlu Wang (@Kingwl), I've started to run the tarball bundle task on this PR at 8a9e234. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey Wenlu Wang (@Kingwl), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Does the playground not supported pull request build now?🤷🏻♂️ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Wesley Wigham (@weswigham) or Orta Therox (@orta) might know |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks for the ping, looks like I need to dig into the playground builder - been red for a week |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Made a PR: microsoft/monaco-typescript#59 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
and with orta/make-monaco-builds@f17ca4a in I can request a playground again - TypeScript Bot (@typescript-bot) pack this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Orta Therox (@orta), I've started to run the tarball bundle task on this PR at 8a9e234. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hey Orta Therox (@orta), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
f17eb88 to
39ae072
Compare
|
Only one pipeline failed with ECONNRESET. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks like this needs to be rebased onto the latest |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
ad70d78 to
b59e4c5
Compare
There was an error while loading. Please reload this page.
|
One more review? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
One more peek Ron Buckton (@rbuckton)? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
up👆 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Wenlu Wang (@Kingwl) I mentioned a case in here. Would you confirm that this is not a bug? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Glad to see things moved since #20378 😀 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What version of typescript will this be available in? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Gaurang Patel (@g-patel) This shipped in TypeScript 4.0. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Nullish Coalescing and Logical Compound Assignments (??=, ||=, &&=)
There was an error while loading. Please reload this page.