Skip to content

Fix test failures on Julia 1.14 - #100

Merged
quinnj-bot[bot] merged 2 commits into
mainfrom
claude/string-methods-114
Nov 19, 2026
Merged

quinnj-bot[bot] merged 2 commits into
mainfrom
claude/string-methods-114

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

The Julia pre CI 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:

  1. Loading InlineStrings turns string.(AbstractString[]) into a Vector{Any}. Code that dispatches on a column's element type (the case in WeakRefStrings changes the behavior of string #2) then gets a MethodError for empty columns. This is the test/runtests.jl:133 failure.
  2. findnext("wör", String31("héllo wörld"), 3) returns a match, while the same call on a String throws StringIndexError on 1.14. This is 54 failures in the search testset. 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 returns Any when more than 3 methods match. Base alone has 3 methods matching string(::AbstractString) on 1.14, and InlineStrings added a fourth.

  • Remove Base.string(a::InlineString) = a. Base's string(s::AbstractString) = s already returns the argument, so string(x::InlineString) still returns x.
  • Change the concatenation method to 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.
  • Add a test that string(String7("ab")) === String7("ab").

Search from inside a character. 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 now hands such a start index to String's own search, so results match String on every Julia version. Earlier versions keep searching from i, like String does there. A valid start index skips the isvalid call unless its byte is a continuation byte.

The broadcast change also widens some Base-only cases, such as Symbol.(AbstractString[]), which is Symbol[] on 1.13 and Any[] on 1.14. That part is upstream and is not fixed here.

Both changes have CHANGELOG entries.

Verification

  • Before, on 1.14.0-alpha2: Test Failed at test/runtests.jl:133, Evaluated: Any == AbstractString. On 1.14.0-beta1, with only the string fix: search has 1233 passed and 54 failed, all findnext(t, s, i) at runtests.jl:896 expecting StringIndexError.
  • After, the full test suite passes on Julia 1.10.11, 1.12.6, 1.13.4, 1.14.0-alpha2, and 1.14.0-beta1 (Docker 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.
  • string returns the same type and value as before for 1 to 5 inline arguments and for mixed String/inline arguments. Two-, three-, and four-argument small-string concatenation still infers a concrete inline type and allocates nothing.
  • Search from a start inside a character matches String for String, String7, and SubString{String} needles. It throws on 1.14.0-beta1 and returns the same match or nothing on 1.13.4.
  • Search cost, measured with Chairmarks on Julia 1.12.6 (Apple M3 Max), interleaving the old method body and the new one in one process with start index 1 and 2: +0.3 to +0.5 ns for String15 to String63 (about 9 to 21 ns before) and +3.5 ns for a String255 search (76 ns before). The added cost is one byte load and compare. String255 costs the most, likely because loading one byte copies the 256-byte value.
  • Adversarial pass: no other one-argument string methods in src/ or ext/, and no internal callers of string. 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, so codeunit(s, i) is in bounds.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.80%. Comparing base (678e1ac) to head (1e49c14).

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

@quinnj-bot quinnj-bot Bot changed the title Keep string.(AbstractString[]) typed on Julia 1.14 Fix test failures on Julia 1.14 Nov 19, 2026
quinnj and others added 2 commits November 18, 2026 22:59
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
quinnj-bot Bot force-pushed the claude/string-methods-114 branch from 6afd445 to 1e49c14 Compare November 19, 2026 06:02
@quinnj-bot
quinnj-bot Bot merged commit 2930a7b into main Nov 19, 2026
13 of 14 checks passed
@quinnj-bot
quinnj-bot Bot deleted the claude/string-methods-114 branch November 19, 2026 06:22
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