Skip to content

Fixed control flow Analysis of aliased discriminants with parenthesized initializers#61788

Merged
jakebailey merged 2 commits into
microsoft:mainfrom
Andarist:fix/aliased-discriminant-prop-access-parenthesis
Nov 11, 2025
Merged

Fixed control flow Analysis of aliased discriminants with parenthesized initializers#61788
jakebailey merged 2 commits into
microsoft:mainfrom
Andarist:fix/aliased-discriminant-prop-access-parenthesis

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #61784

Copilot AI review requested due to automatic review settings May 31, 2025 13:57
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog May 31, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 31, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where discriminant properties aliased through parenthesized or destructured initializers weren't correctly recognized in control-flow analysis.

  • Added comprehensive tests covering both direct and parenthesized/destructured alias patterns.
  • Refactored the alias resolution logic in the type checker to use a helper that skips parentheses.
  • Introduced getCandidateVariableDeclarationInitializer to centralize initializer extraction.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/cases/conformance/controlFlow/controlFlowAliasing2.ts New tests for aliased discriminants with various initializer forms
tests/baselines/reference/controlFlowAliasing2.symbols Baseline update for the new conformance tests
src/compiler/checker.ts Extracted initializer logic into a helper and updated alias-matching branches
Comments suppressed due to low confidence (1)

src/compiler/checker.ts:29266

  • [nitpick] Consider renaming this helper to something shorter like getInitializerSkippingParens or extractInitializer for improved readability.
function getCandidateVariableDeclarationInitializer(node: Node) {

Comment thread src/compiler/checker.ts
Comment thread src/compiler/checker.ts
Comment thread src/compiler/checker.ts
@Harpush

Harpush commented Jul 1, 2025

Copy link
Copy Markdown

Any chance for this passing?

@jakebailey

Copy link
Copy Markdown
Member

@typescript-bot test it

@typescript-bot

typescript-bot commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started
run dt ✅ Started ✅ Results
perf test this faster ✅ Started

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/61788/merge:

Everything looks good!

@Harpush

Harpush commented Aug 29, 2025

Copy link
Copy Markdown

Is there a chance for it landing anytime soon?

@Harpush

Harpush commented Nov 1, 2025

Copy link
Copy Markdown

Anything new here?

@jakebailey

Copy link
Copy Markdown
Member

At the very least, a merge from main (and a review of course).

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 3, 2025
@Andarist

Andarist commented Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

I synced it with main - so now it's only missing a review :)

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 11, 2025
@jakebailey jakebailey merged commit 4a957b7 into microsoft:main Nov 11, 2025
33 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 11, 2025
@microsoft microsoft locked as resolved and limited conversation to collaborators May 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Parenthesis break narrowing.

6 participants