throw LightBoundsError instead of BoundsError#37
Merged
jakobnissen merged 7 commits intoBioJulia:masterfrom Feb 20, 2026
Merged
throw LightBoundsError instead of BoundsError#37jakobnissen merged 7 commits intoBioJulia:masterfrom
LightBoundsError instead of BoundsError#37jakobnissen merged 7 commits intoBioJulia:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #37 +/- ##
==========================================
+ Coverage 97.88% 97.89% +0.01%
==========================================
Files 10 10
Lines 331 333 +2
==========================================
+ Hits 324 326 +2
Misses 7 7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jakobnissen
requested changes
Feb 19, 2026
Member
|
This is a good idea. Too bad that BoundsError was designed that way. I'm going to roll it up with #19 when releasing v0.4 |
Member
|
LGTM. Its still a draft, but whenever you set it ready to merge, I’ll review the package for whether any APIs could use an overhaul, then release v0.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context: While
BoundsErroris common in the Julia world, its use is problematic for compiler optimizations. More specifically, Julia is gaining the ability to eliminate heap allocations as of recently, even for code that is not eliminated by dead code elimination or eliminated by constant folding. After the compiler gains interprocedural escape analysis capabilities, elimination of heap allocations should become applicable more often. The problem withBoundsErroris that aBoundsErrorvalue holds a reference to the array that was attempted to be indexed out-of-bounds. Thus aBoundsErrorthrow escapes the value of the array. Thus aBoundsErrorthrow makes the elimination of the underlying heap allocation impossible, unless the throw is first eliminated by@inboundsor by other compiler optimizations.The
LightBoundsErrorexception from package LightBoundsErrors.jl addresses this by storingtypeof(array)andaxes(array)instead of storingarray. The new package is already adopted as a dependency by FixedSizeArrays.jl.Switching from
BoundsErrortoLightBoundsErrorcould hypothetically break a dependent of MemoryViews, in case a dependent branches on something likeexception isa BoundsErrorwhile error handling.Auto-checklist: