Skip to content

Conversation

nsajko
Copy link
Member

@nsajko nsajko commented Mar 30, 2025

Achieve better abstract return type inference by moving the typeassert to after the branch, so it affects both sides of the branch. Also deduplicate typeof(x) calls.

@nsajko nsajko added backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 labels Mar 30, 2025
@KristofferC KristofferC mentioned this pull request Mar 31, 2025
36 tasks
@KristofferC
Copy link
Member

(new test fails)

@KristofferC KristofferC mentioned this pull request Mar 31, 2025
71 tasks
@nsajko
Copy link
Member Author

nsajko commented Mar 31, 2025

Oof, sorry, I made a typo while trying this out in the REPL (x instead of y in the first part of the branch), which resulted in a misleadingly good result.

The test can be made to pass by applying the typeassert to the final return value, instead of to just one side of the branch, so that's what I'll do instead.

@nsajko nsajko changed the title deduplicate code within oftype for better type inference better abstract inference for oftype Mar 31, 2025
Achieve better abstract return type inference by moving the typeassert
to after the branch, so it affects both sides of the branch. Also
deduplicate `typeof(x)` calls.
@nsajko nsajko changed the title better abstract inference for oftype better abstract type inference for oftype Mar 31, 2025
@nsajko nsajko force-pushed the better_inference_for_oftype_via_common_subexpression_elimination branch from f5083c4 to 0c0dfc4 Compare March 31, 2025 14:35
@nsajko nsajko removed backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 labels Mar 31, 2025
@nsajko
Copy link
Member Author

nsajko commented Mar 31, 2025

The PR doesn't just deduplicate code any more, so gonna refrain from requesting backports. Sorry for the noise.

@nsajko nsajko closed this Jul 12, 2025
@nsajko nsajko deleted the better_inference_for_oftype_via_common_subexpression_elimination branch July 12, 2025 02:47
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.

2 participants