Skip to content

Only remove typeMap from typeMapsPath if added by the current frame in CheckForCycles - #4688

Open
lqkhanh295 wants to merge 1 commit into
LuckyPennySoftware:mainfrom
lqkhanh295:fix/cycle-check-typemaps-path-premature-removal
Open

lqkhanh295 wants to merge 1 commit into
LuckyPennySoftware:mainfrom
lqkhanh295:fix/cycle-check-typemaps-path-premature-removal

Conversation

@lqkhanh295

Copy link
Copy Markdown

Fixes #4654

In TypeMapPlanBuilder.CheckForCycles, typeMapsPath.Remove(typeMap) was called unconditionally at the end of each frame. When a cyclic member caused recursion into a type map that was already present in typeMapsPath, the inner call's Remove took it off the path while the outer frame was still iterating its remaining members. As noted in #4654, this caused subsequent members in the outer frame to evaluate against a shortened path, making inlining depth decisions dependent on property declaration order.

This change tracks whether the current frame actually added typeMap to typeMapsPath via var added = typeMapsPath.Add(typeMap) and only removes it in finally if added is true. This preserves ancestor paths for outer frames while continuing to detect cycles properly. Added unit tests for property declaration order independence.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 18:43

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@CLAassistant

CLAassistant commented Nov 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CheckForCycles removes the type map from typeMapsPath while its members are still being iterated

3 participants