-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fixed an issue with ReduceLabel
flows spoiling node reachability cache
#61265
Open
Andarist
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
Andarist:fix/reduce-label-spoiling-reachability-cache
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+408
−16
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
This file contains 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,113 @@ | ||
//// [tests/cases/compiler/reachabilityChecks9.ts] //// | ||
|
||
=== reachabilityChecks9.ts === | ||
// https://github.com/microsoft/TypeScript/issues/61259 | ||
|
||
const a = (v: 1 | 2) => { | ||
>a : Symbol(a, Decl(reachabilityChecks9.ts, 2, 5)) | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 2, 11)) | ||
|
||
try { | ||
switch (v) { | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 2, 11)) | ||
|
||
case 1: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 2, 11)) | ||
|
||
case 2: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 2, 11)) | ||
} | ||
} finally { | ||
console.log("exit"); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
}; | ||
|
||
const b = (v: number) => { | ||
>b : Symbol(b, Decl(reachabilityChecks9.ts, 15, 5)) | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 15, 11)) | ||
|
||
try { | ||
switch (v) { | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 15, 11)) | ||
|
||
case 1: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 15, 11)) | ||
|
||
default: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 15, 11)) | ||
} | ||
} finally { | ||
console.log("exit"); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
}; | ||
|
||
const c = (v: 1 | 2) => { | ||
>c : Symbol(c, Decl(reachabilityChecks9.ts, 28, 5)) | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 28, 11)) | ||
|
||
try { | ||
switch (v) { | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 28, 11)) | ||
|
||
case 1: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 28, 11)) | ||
|
||
case 2: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 28, 11)) | ||
} | ||
} finally { | ||
if (Math.random()) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
console.log("exit"); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
} | ||
}; | ||
|
||
const d = (v: number) => { | ||
>d : Symbol(d, Decl(reachabilityChecks9.ts, 43, 5)) | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 43, 11)) | ||
|
||
try { | ||
switch (v) { | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 43, 11)) | ||
|
||
case 1: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 43, 11)) | ||
|
||
default: | ||
return v; | ||
>v : Symbol(v, Decl(reachabilityChecks9.ts, 43, 11)) | ||
} | ||
} finally { | ||
if (Math.random()) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
console.log("exit"); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
} | ||
}; | ||
|
Oops, something went wrong.
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.
as the comment in this block says:
// Cache is unreliable once we start adjusting labels
We can't let this
isReachableFlowNodeWorker
call here to populate the cache as that would create entries based on the temporarilyantecedent
(s). Anything computed below this call can't be preserved, at least not without including the id of thisReduceLabel
flow in the cache key or smth.So this disables cache writes. As later on that would be used on the same shared flow but with "correct"
antecedent
s (and that's the only result the compiler should cache and trust).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'm still considering 2 things here:
flowNodeReachable[getFlowNodeId(target)]
?I have not been able to produce a test case that would prove either to be required so far but I have only spent a little bit of time on it.
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.
cc @ahejlsberg who has been thinking about this sort of thing recently and I believe had ideas on how to simplify the flow node logic here