fix: keep error paths trim-verifier-clean#472
Open
quinnj wants to merge 1 commit into
Open
Conversation
…ring, LazyValue) Three error-path constructions made JSON.jl responsible for the majority of --trim verifier errors in downstream juliac builds (measured: 418 of 474 in an isolated parse+write workload; 169 of 374 in a real HTTP-server graph): - jsonreadstyle: `repr(::Symbol)` routes through the @nospecialize'd show_unquoted_quote_expr, making Base's entire Expr-show machinery reachable — hundreds of unresolvable dynamic calls from one throw. Plain symbol interpolation prints identically for standard symbols. - unknownfielderror: keys arrive as PtrString (no print/show methods), so `repr(key)` fell back to the generic struct show. Convert PtrString to String explicitly (also a nicer message: the actual key text instead of a PtrString struct dump); string(key) for Int/other scalar keys. - make fallback: `"cannot parse $x"` interpolated a LazyValue, whose show renders via the array-display machinery; use the same "cannot parse json" message as the sibling error paths. No behavior change outside these three messages; full test suite green.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #472 +/- ##
==========================================
+ Coverage 90.41% 90.42% +0.01%
==========================================
Files 7 7
Lines 1419 1421 +2
==========================================
+ Hits 1283 1285 +2
Misses 136 136 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
fix: keep error paths trim-verifier-clean
Three error-message constructions made JSON.jl responsible for the majority of
--trimverifier errors in downstream juliac builds. Measured on 1.14-DEV (juliac --trim=safe --experimental):parse, typedparse,jsonof Dict and struct): 474 → 56 verifier errorsThe three sites (all in
src/parse.jl)1.
jsonreadstyle—repr(::Symbol)in a throw: 165 errors from one line.show(::Symbol)routes through the@nospecializedshow_unquoted_quote_expr, which makes Base's entire Expr-show machinery (show_unquoted,show_block,show_generator, …) reachable from this error path — each with its own unresolvable dynamic call. Plain symbol interpolation (:$(unknown_fields)) prints identically for standard symbols and lowers toprint(::IO, ::Symbol), a plainwrite.2.
unknownfielderror—repr(key)wherekey::PtrString: generic struct-show fallback.PtrStringhas noprint/showmethods, so bothreprand plain interpolation fall back toshow_default(dynamicsizeof/fieldnamesites under trim). Now convertsPtrString → Stringexplicitly — which also improves the message: the actual member name instead of aPtrString(Ptr{UInt8}…)struct dump. Keys can also beInt(array-into-struct with extra elements — covered by the existing@test_throwscases), hence thestring(key)fallback method.3.
makefallback —"cannot parse $x"interpolated aLazyValue.Its
showrenders through the array-display machinery (print_matrixetc.). This branch is unreachable in practice (allJSONTypesare covered above it); it now uses the same"cannot parse json"message as the sibling error paths at lines 360/506.Behavior change
Error-message text only, in the three messages above. No API or parsing behavior changes. Full test suite passes, including the trim compile tests.
Not addressed here (follow-ups)
The 56 remaining workload errors are not JSON error paths: StructUtils field-matching (
findfield/indexed_iterate) and write-closure dispatch (applyeach), and the Parsers BigFloat overflow-fallback digits machinery reached fromparsenumber. Those want fixes in StructUtils/Parsers respectively — with them, materializingparsecould graduate into the trim test workload's covered entrypoints (the carve-out documented intest/json_trim_public_entrypoints.jl).