Skip to content

Add regression cases for union alias display - #5454

Closed
asukaminato0721 wants to merge 1 commit into
meta:mainfrom
asukaminato0721:union-alias-regressions
Closed

asukaminato0721 wants to merge 1 commit into
meta:mainfrom
asukaminato0721:union-alias-regressions

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Record regression cases before replacing the union display changes in #2466. Related to #1115.

The tests cover an unannotated decorator, an annotated alias combined with another type, repeated union composition, generic substitution that collapses to the alias, and a shared alias imported through two modules.

Test checks named and anonymous unions through twenty nested tuple levels. Each must visit 5 * depth + 1 Type nodes. This detects the exponential display-payload duplication reported in the old review.

This PR contains tests only. The repeated-composition test marks the existing loss of the alias name as a known display bug. Its semantic assert_type checks that no union members disappear.

  • I am a human, and I fully understand the code I am submitting.

Test Plan

The following checks passed on Linux:

cargo test -p pyrefly --lib alias_display_
cargo test -p pyrefly --lib test_inferred_decorator_union_alias_display
cargo test -p pyrefly_types test_union_alias_nested_tuple_growth_is_linear
python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension

The nested traversal test checks named and anonymous unions through twenty levels. Both visit 5 * depth + 1 type nodes.

Record inferred decorator returns, repeated union composition, generic collapse, and imported alias identity before changing presentation. Check nested named and anonymous unions have the same linear visitor growth.
@meta-cla meta-cla Bot added the cla signed label Oct 29, 2026
@asukaminato0721
asukaminato0721 marked this pull request as ready for review October 29, 2026 17:10
@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D128365598. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@stroxler stroxler 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.

Review automatically exported from Phabricator review in Meta.

@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 12064f9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants