Skip to content

Achieve type stability for indexing by avoiding variable boxing, including for ranges#530

Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom
Ickaser:typestable-indexing
Jan 22, 2026
Merged

Achieve type stability for indexing by avoiding variable boxing, including for ranges#530
ChrisRackauckas merged 1 commit intoSciML:masterfrom
Ickaser:typestable-indexing

Conversation

@Ickaser
Copy link
Contributor

@Ickaser Ickaser commented Jan 22, 2026

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • [] The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Following on from #525 , I realized that #526 didn't fix anything for ranges e.g. vec[1, 1:end] (which is the indexing I actually used), and having taken a look at Cthulhu output I could tell something was off in the indexing since there were lots of boxed variables.

Eventually I worked out that the boxes were not due to closures, but due to variables being defined differently in different branches within the same scope. So I broke up the branches across a couple different functions, and that was enough to fix inference.

I am not committed to the names of any of these functions necessarily, and there may be some other improvements possible to avoid repeating the same code (the AI generated a lot of repetitive code).

@Ickaser Ickaser changed the title Achieve type stability by avoiding variable boxing, including for ranges Achieve type stability for indexing by avoiding variable boxing, including for ranges Jan 22, 2026
@ChrisRackauckas ChrisRackauckas merged commit 2cc6009 into SciML:master Jan 22, 2026
25 of 27 checks passed
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