Repository navigation
Fix test failures on Julia 1.14 - #100
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #100 +/- ##
==========================================
+ Coverage 91.50% 91.80% +0.29%
==========================================
Files 5 5
Lines 730 744 +14
==========================================
+ Hits 668 683 +15
+ Misses 62 61 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Julia 1.14 computes a broadcast's result eltype by inferring the fused
call, so `string(::AbstractString)` is subject to inference's 3-method
limit. Base alone has 3 matching methods there, and the extra
`string(::InlineString)` method made `string.(AbstractString[])` a
`Vector{Any}` (test/runtests.jl:133, issue #2).
Drop the one-argument method (Base's `string(s::AbstractString) = s`
already returns the argument) and require two or more arguments for the
vararg concatenation method, so no InlineStrings method matches a
one-argument `string` call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Julia 1.14 (JuliaLang/julia#64515) makes `findnext(t, s::String, i)` throw `StringIndexError` when `i` is inside a character and `t` has more than one character. The inline-haystack `_searchindex` searched from `i` regardless, so the `search` testset fails 54 times on 1.14.0-beta1. That testset never ran on 1.14 before, because the `string.(AbstractString[])` failure aborted the suite first. Hand a start index inside a character to `String`'s own search, so the result matches `String` on every Julia version. Only a continuation byte can be inside a character, so valid starts skip `isvalid`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj-bot
Bot
force-pushed
the
claude/string-methods-114
branch
from
November 19, 2026 06:02
6afd445 to
1e49c14
Compare
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.
Why
The
Julia preCI job (1.14.0-beta1) fails on every InlineStrings PR. Two Julia 1.14 changes cause it, and users on 1.14 would see both:string.(AbstractString[])into aVector{Any}. Code that dispatches on a column's element type (the case in WeakRefStrings changes the behavior ofstring#2) then gets aMethodErrorfor empty columns. This is thetest/runtests.jl:133failure.findnext("wör", String31("héllo wörld"), 3)returns a match, while the same call on aStringthrowsStringIndexErroron 1.14. This is 54 failures in thesearchtestset. That testset never ran on 1.14 before, because failure 1 aborted the suite first.What changed
One-argument
string. Julia 1.14 picks a broadcast's result element type by inferring the call inside a helper function (JuliaLang/julia#62564). Inference gives up and returnsAnywhen more than 3 methods match. Base alone has 3 methods matchingstring(::AbstractString)on 1.14, and InlineStrings added a fourth.Base.string(a::InlineString) = a. Base'sstring(s::AbstractString) = salready returns the argument, sostring(x::InlineString)still returnsx.string(a::InlineString, b::InlineString, c::InlineString...). It needs two or more arguments now, so it no longer matches a one-argument call. Calls with two or more arguments dispatch as before.string(String7("ab")) === String7("ab").Search from inside a character. Julia 1.14 (JuliaLang/julia#64515) makes
findnext(t, s::String, i)throwStringIndexErrorwheniis inside a character andthas more than one character. The inline-haystack_searchindexnow hands such a start index toString's own search, so results matchStringon every Julia version. Earlier versions keep searching fromi, likeStringdoes there. A valid start index skips theisvalidcall unless its byte is a continuation byte.The broadcast change also widens some Base-only cases, such as
Symbol.(AbstractString[]), which isSymbol[]on 1.13 andAny[]on 1.14. That part is upstream and is not fixed here.Both changes have CHANGELOG entries.
Verification
Test Failed at test/runtests.jl:133,Evaluated: Any == AbstractString. On 1.14.0-beta1, with only thestringfix:searchhas 1233 passed and 54 failed, allfindnext(t, s, i)atruntests.jl:896expectingStringIndexError.julia:1.14.0-beta1). After rebasing onto Make findlast, findprev, and inline-needle searches match String #98, I reran 1.10.11, 1.13.4, and 1.14.0-beta1, and all pass.stringreturns the same type and value as before for 1 to 5 inline arguments and for mixedString/inline arguments. Two-, three-, and four-argument small-string concatenation still infers a concrete inline type and allocates nothing.StringforString,String7, andSubString{String}needles. It throws on 1.14.0-beta1 and returns the same match ornothingon 1.13.4.String15toString63(about 9 to 21 ns before) and +3.5 ns for aString255search (76 ns before). The added cost is one byte load and compare.String255costs the most, likely because loading one byte copies the 256-byte value.stringmethods insrc/orext/, and no internal callers ofstring. The 3- and 4-argument small-string methods are more specific than the new vararg signature.string()with no arguments returns""before and after. Aqua's ambiguity check passes on all five versions. The search change runs after the bounds check, socodeunit(s, i)is in bounds.🤖 Generated with Claude Code