Fix mapreduce type-stability on Julia 1.10 using @generated functions #499
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the type-stability issue in
mapreduceforArrayPartitionon Julia 1.10 that was blocking PR #444.Problem
The
mapreducefunction was not type-stable on Julia 1.10. The issue was caused by type inference problems with kwargs and closures in generator expressions. While Julia 1.11 handled this correctly, Julia 1.10 would inferAnyinstead of the concrete return type.Solution
@generatedfunctions (_mapreduce_impland_mapreduce_impl_init) to unroll the tuple iteration at compile timeinitparameter semantics (init applied once at the outer level, not per-partition)Additional Fix
ArrayInterfaceimport intest/named_array_partition_tests.jlTest Results
Test plan
Pkg.test()on Julia 1.10Pkg.test()on Julia 1.11@inferred sum(ArrayPartition(ArrayPartition(zeros(4,4))))returnsFloat64🤖 Generated with Claude Code