Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,8 @@ export class Compiler extends DiagnosticEmitter {
if (terminates || isLast || innerFlow.isAny(FlowFlags.BREAKS | FlowFlags.CONDITIONALLY_BREAKS)) {
commonCategorical &= innerFlow.flags;
}
commonConditional |= innerFlow.flags & FlowFlags.ANY_CONDITIONAL;

commonConditional |= innerFlow.deriveConditionalFlags();

// Switch back to the parent flow
innerFlow.unset(
Expand Down
20 changes: 20 additions & 0 deletions src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,26 @@ export class Flow {
/** Unsets the specified flag or flags. */
unset(flag: FlowFlags): void { this.flags &= ~flag; }

deriveConditionalFlags(): FlowFlags {
let condiFlags = this.flags & FlowFlags.ANY_CONDITIONAL;
if (this.is(FlowFlags.RETURNS)) {
condiFlags |= FlowFlags.CONDITIONALLY_RETURNS;
}
if (this.is(FlowFlags.THROWS)) {
condiFlags |= FlowFlags.CONDITIONALLY_THROWS;
}
if (this.is(FlowFlags.BREAKS)) {
condiFlags |= FlowFlags.CONDITIONALLY_BREAKS;
}
if (this.is(FlowFlags.CONTINUES)) {
condiFlags |= FlowFlags.CONDITIONALLY_CONTINUES;
}
if (this.is(FlowFlags.ACCESSES_THIS)) {
condiFlags |= FlowFlags.CONDITIONALLY_ACCESSES_THIS;
}
return condiFlags;
}

/** Forks this flow to a child flow. */
fork(resetBreakContext: bool = false): Flow {
var branch = new Flow(this.parentFunction);
Expand Down