Skip to content

Use type inference for blocktype instead of runtime mapreduce#255

Merged
mtfishman merged 1 commit intomainfrom
mf/fix-test-broken
Apr 16, 2026
Merged

Use type inference for blocktype instead of runtime mapreduce#255
mtfishman merged 1 commit intomainfrom
mf/fix-test-broken

Conversation

@mtfishman
Copy link
Copy Markdown
Member

Summary

  • Replace runtime mapreduce(typeof, promote_type, blocks(a)) in blocktype(::AbstractArray) with eltype_inferred(blocks(a)), which uses static type parameters by default.
  • Add eltype_inferred(::BlocksView) specialization using promote_op(getindex, ...) for a tighter result than the abstract eltype.
  • Relax the BlockedArray blocktype test from @constinferred ... <: SubArray to blocktype(a) <: AbstractMatrix{elt}, since the inferred type depends on the parent array and may be abstract or a Union.

The previous implementation relied on aggressive const-propagation that broke on Julia v1.12.6 x86_64 (JuliaLang/julia#57582 changed inference behavior). It also errored on empty arrays.

Test plan

  • test_basics.jl passes locally (fresh subprocess, all 6 arraytype/eltype combos)
  • CI passes on Julia LTS and Julia 1

🤖 Generated with Claude Code

The generic `blocktype(::AbstractArray)` previously used
`mapreduce(typeof, promote_type, blocks(a))` which relied on
aggressive const-propagation for type stability and failed on
empty arrays. Replace with `eltype_inferred(blocks(a))` which
uses static type parameters by default, with a `BlocksView`
specialization that uses `promote_op` for a tighter result.

Relax the `BlockedArray` `blocktype` test from `@constinferred`
to a plain subtype check since the inferred type may be abstract
or a Union depending on the parent array type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.99%. Comparing base (b89c568) to head (2c9fff8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #255      +/-   ##
==========================================
+ Coverage   71.94%   71.99%   +0.04%     
==========================================
  Files          36       36              
  Lines        2032     2032              
==========================================
+ Hits         1462     1463       +1     
+ Misses        570      569       -1     
Flag Coverage Δ
docs 5.83% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfishman mtfishman enabled auto-merge (squash) April 16, 2026 19:48
@mtfishman mtfishman merged commit ef21782 into main Apr 16, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/fix-test-broken branch April 16, 2026 20:10
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.

1 participant