Skip to content

Fix Tuple#to_a(&) for arbitrary block output type#15431

Merged
straight-shoota merged 3 commits intocrystal-lang:masterfrom
straight-shoota:fix/tuple-to_a
Feb 8, 2025
Merged

Fix Tuple#to_a(&) for arbitrary block output type#15431
straight-shoota merged 3 commits intocrystal-lang:masterfrom
straight-shoota:fix/tuple-to_a

Conversation

@straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Feb 7, 2025

Resolves #15430

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:collection labels Feb 7, 2025
@straight-shoota straight-shoota self-assigned this Feb 7, 2025
Comment on lines -548 to -552
{% if compare_versions(Crystal::VERSION, "1.1.0") < 0 %}
to_a(&.itself.as(Union(*T)))
{% else %}
to_a(&.itself)
{% end %}
Copy link
Member Author

@straight-shoota straight-shoota Feb 7, 2025

Choose a reason for hiding this comment

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

With this change, the explicit cast here is always necessary, even after 1.1.0 because the compiler couldn't figure out the output type of &.itself.

@straight-shoota straight-shoota added this to the 1.16.0 milestone Feb 7, 2025
@straight-shoota straight-shoota changed the title Fix Tuple#to_a(&) for arbitrary block output type Fix Tuple#to_a(&) for arbitrary block output type Feb 7, 2025
@straight-shoota straight-shoota merged commit 687dce2 into crystal-lang:master Feb 8, 2025
73 checks passed
@straight-shoota straight-shoota deleted the fix/tuple-to_a branch February 8, 2025 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:collection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tuple#to_a(&) is broken when block's output type doesn't match the tuple's element type union

2 participants