Skip to content

Conversation

@Andarist
Copy link
Contributor

fixes #61259

const saveAntecedents = target.antecedent;
target.antecedent = (flow as FlowReduceLabel).node.antecedents;
const result = isReachableFlowNodeWorker((flow as FlowReduceLabel).antecedent, /*noCacheCheck*/ false);
const result = isReachableFlowNodeWorker((flow as FlowReduceLabel).antecedent, FlowNodeReachableCacheFlags.None);
Copy link
Contributor Author

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 temporarily antecedent(s). Anything computed below this call can't be preserved, at least not without including the id of this ReduceLabel 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" antecedents (and that's the only result the compiler should cache and trust).

Copy link
Contributor Author

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:

  • should this code maybe save & restore flowNodeReachable[getFlowNodeId(target)]?
  • should reads be permanently disabled here? this would make the previous consideration obsolete

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.

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, Corsa still suffers from this (checked at microsoft/typescript-go@a92eff4 )

@Andarist Andarist force-pushed the fix/reduce-label-spoiling-reachability-cache branch from 2a860e8 to 4552c20 Compare February 25, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Exhaustive switch case with returns can mark a finally block as unreachable

2 participants