-
Notifications
You must be signed in to change notification settings - Fork 13k
Bind RHS of comma expressions too #47049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d6f983
Add test for initial behavior
jakebailey 6c9ec85
Apply previous comma fix to right side of comma expression
jakebailey 0fe65fd
Test multiple commas
jakebailey 5be2594
Remove LHS wording from comment
jakebailey 6a1fa03
Move maybeBindExpressionFlowIfCall into onLeft and onRight
jakebailey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/controlFlowCommaExpressionAssertionMultiple.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//// [controlFlowCommaExpressionAssertionMultiple.ts] | ||
function Narrow<T>(value: any): asserts value is T {} | ||
|
||
function func(foo: any, bar: any) { | ||
Narrow<number>(foo), Narrow<string>(bar); | ||
foo; | ||
bar; | ||
} | ||
|
||
function func2(foo: any, bar: any, baz: any) { | ||
Narrow<number>(foo), Narrow<string>(bar), Narrow<boolean>(baz); | ||
foo; | ||
bar; | ||
baz; | ||
} | ||
|
||
|
||
//// [controlFlowCommaExpressionAssertionMultiple.js] | ||
function Narrow(value) { } | ||
function func(foo, bar) { | ||
Narrow(foo), Narrow(bar); | ||
foo; | ||
bar; | ||
} | ||
function func2(foo, bar, baz) { | ||
Narrow(foo), Narrow(bar), Narrow(baz); | ||
foo; | ||
bar; | ||
baz; | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/controlFlowCommaExpressionAssertionMultiple.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
=== tests/cases/compiler/controlFlowCommaExpressionAssertionMultiple.ts === | ||
function Narrow<T>(value: any): asserts value is T {} | ||
>Narrow : Symbol(Narrow, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 0)) | ||
>T : Symbol(T, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 16)) | ||
>value : Symbol(value, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 19)) | ||
>value : Symbol(value, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 19)) | ||
>T : Symbol(T, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 16)) | ||
|
||
function func(foo: any, bar: any) { | ||
>func : Symbol(func, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 53)) | ||
>foo : Symbol(foo, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 2, 14)) | ||
>bar : Symbol(bar, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 2, 23)) | ||
|
||
Narrow<number>(foo), Narrow<string>(bar); | ||
>Narrow : Symbol(Narrow, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 0)) | ||
>foo : Symbol(foo, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 2, 14)) | ||
>Narrow : Symbol(Narrow, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 0)) | ||
>bar : Symbol(bar, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 2, 23)) | ||
|
||
foo; | ||
>foo : Symbol(foo, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 2, 14)) | ||
|
||
bar; | ||
>bar : Symbol(bar, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 2, 23)) | ||
} | ||
|
||
function func2(foo: any, bar: any, baz: any) { | ||
>func2 : Symbol(func2, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 6, 1)) | ||
>foo : Symbol(foo, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 15)) | ||
>bar : Symbol(bar, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 24)) | ||
>baz : Symbol(baz, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 34)) | ||
|
||
Narrow<number>(foo), Narrow<string>(bar), Narrow<boolean>(baz); | ||
>Narrow : Symbol(Narrow, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 0)) | ||
>foo : Symbol(foo, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 15)) | ||
>Narrow : Symbol(Narrow, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 0)) | ||
>bar : Symbol(bar, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 24)) | ||
>Narrow : Symbol(Narrow, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 0, 0)) | ||
>baz : Symbol(baz, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 34)) | ||
|
||
foo; | ||
>foo : Symbol(foo, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 15)) | ||
|
||
bar; | ||
>bar : Symbol(bar, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 24)) | ||
|
||
baz; | ||
>baz : Symbol(baz, Decl(controlFlowCommaExpressionAssertionMultiple.ts, 8, 34)) | ||
} | ||
|
55 changes: 55 additions & 0 deletions
55
tests/baselines/reference/controlFlowCommaExpressionAssertionMultiple.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
=== tests/cases/compiler/controlFlowCommaExpressionAssertionMultiple.ts === | ||
function Narrow<T>(value: any): asserts value is T {} | ||
>Narrow : <T>(value: any) => asserts value is T | ||
>value : any | ||
|
||
function func(foo: any, bar: any) { | ||
>func : (foo: any, bar: any) => void | ||
>foo : any | ||
>bar : any | ||
|
||
Narrow<number>(foo), Narrow<string>(bar); | ||
>Narrow<number>(foo), Narrow<string>(bar) : void | ||
>Narrow<number>(foo) : void | ||
>Narrow : <T>(value: any) => asserts value is T | ||
>foo : any | ||
>Narrow<string>(bar) : void | ||
>Narrow : <T>(value: any) => asserts value is T | ||
>bar : any | ||
|
||
foo; | ||
>foo : number | ||
|
||
bar; | ||
>bar : string | ||
} | ||
|
||
function func2(foo: any, bar: any, baz: any) { | ||
>func2 : (foo: any, bar: any, baz: any) => void | ||
>foo : any | ||
>bar : any | ||
>baz : any | ||
|
||
Narrow<number>(foo), Narrow<string>(bar), Narrow<boolean>(baz); | ||
>Narrow<number>(foo), Narrow<string>(bar), Narrow<boolean>(baz) : void | ||
>Narrow<number>(foo), Narrow<string>(bar) : void | ||
>Narrow<number>(foo) : void | ||
>Narrow : <T>(value: any) => asserts value is T | ||
>foo : any | ||
>Narrow<string>(bar) : void | ||
>Narrow : <T>(value: any) => asserts value is T | ||
>bar : any | ||
>Narrow<boolean>(baz) : void | ||
>Narrow : <T>(value: any) => asserts value is T | ||
>baz : any | ||
|
||
foo; | ||
>foo : number | ||
|
||
bar; | ||
>bar : string | ||
|
||
baz; | ||
>baz : boolean | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
tests/cases/compiler/controlFlowCommaExpressionAssertionMultiple.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function Narrow<T>(value: any): asserts value is T {} | ||
|
||
function func(foo: any, bar: any) { | ||
Narrow<number>(foo), Narrow<string>(bar); | ||
foo; | ||
bar; | ||
} | ||
|
||
function func2(foo: any, bar: any, baz: any) { | ||
Narrow<number>(foo), Narrow<string>(bar), Narrow<boolean>(baz); | ||
foo; | ||
bar; | ||
baz; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this be in
onExit
and notonRight
?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look up a bit, the
node.left
is processed inonOperator
, presumably because there's some work that is completed afteronLeft
is completed. That's how it was added in #44487.I tried putting it into
onRight
first and hit infinite recursion, then realized that the other call wasn't inonLeft
and moved it down.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I can get away with moving these around, though, and try running them after
maybeBind
inonLeft
andonRight
instead. I'll try it. It'd sure look less weird.This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved things around to be a little less surprising.