Skip to content

Conversation

@devmotion
Copy link
Contributor

Based on #419 since LazyString and lazy"..." are only available in Julia >= 1.8.


The PR changes all error messages to lazy strings to delay string interpolation and printing of the involved quantities until the error message is displayed (and hence skip it completely if the error path is not hit). Using LazyStrings in error messages generally also helps with type inference (see e.g. JuliaLang/julia#58672 and JuliaLang/julia#54737).

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.82%. Comparing base (6f61dc3) to head (ce2b0b0).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #420      +/-   ##
==========================================
- Coverage   99.91%   99.82%   -0.09%     
==========================================
  Files           8        8              
  Lines        1147     1154       +7     
==========================================
+ Hits         1146     1152       +6     
- Misses          1        2       +1     

☔ 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.

@inline function setindex!(F::AbstractFill{T, N}, v, kj::Vararg{Integer, N}) where {T, N}
@boundscheck checkbounds(F, kj...)
v == getindex_value(F) || throw(ArgumentError("Cannot setindex! to $v for an AbstractFill with value $(getindex_value(F))."))
v == getindex_value(F) || throw(ArgumentError(LazyString("Cannot setindex! to ", v, " for an AbstractFill with value ", getindex_value(F), ".")))
Copy link
Member

Choose a reason for hiding this comment

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

Why not use the @lazy_str macro?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to avoid the additional overhead. I also had the impression that in Base usually LazyString is used for error messages, not @lazy_str - I assumed also to avoid overhead.

Copy link
Member

Choose a reason for hiding this comment

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

Usually that's because of bootstrapping issues, as some parts of Base are loaded before the macro is defined. Packages don't have the same issue. I imagine the overhead would be minimal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah true, that could be another explanation.

The overhead might be small but to me it seemed strange to provide the information/variables in a form that required string processing and parsing: https://github.com/JuliaLang/julia/blob/master/base%2Fstrings%2Flazy.jl#L67-L77

@jishnub jishnub merged commit af7b57c into JuliaArrays:master Nov 6, 2025
27 of 28 checks passed
@devmotion devmotion deleted the dw/lazy branch November 6, 2025 08:52
@devmotion
Copy link
Contributor Author

@jishnub could you maybe register a new release? It seems the version number was already updated in #419.

@jishnub
Copy link
Member

jishnub commented Nov 6, 2025

@devmotion JuliaRegistries/General#141992

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