The unsafe-code report walks a checked term by its shape - #990
Draft
nicolas-abril wants to merge 1 commit into
Draft
nicolas-abril wants to merge 1 commit into
nicolas-abril wants to merge 1 commit into
Conversation
cli_report finds the defs that rely on unsafe or foreign code by walking the elaborated term of every def reachable from the file. term_refs did it with Object.entries on every object, which allocates a pair array per field per node. It now switches on the node's tag and recurses into the known children. The type annotations a checked subterm carries are still walked, so every ref set and every verdict is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
The unsafe-code report walks a checked term by its shape
cli_reportdecides which of a file's defs rely on unsafe or foreign code by walking the elaborated term of every def reachable from the file, Base's included. The walk was generic:Object.entrieson every object, into every field but the span. That allocates a pair array per field per node, and it descends into the checker's type annotations, whichCheckandInferstore as the value of aVaron every checked subterm: about half of the nodes it visits, many of them shared and visited again.term_refsnow switches on the node's tag and recurses into its known children. The annotations are still walked, so the ref set of every def and every verdict is unchanged: identical on all 16 demos and on the six tests that expect a verdict (io/far_types,io/marshal_imported_nullary_type,import/unsafe_used,import/unsafe_lib,check/unsafe_field,check/unsafe_relies), which pass locally.Measured with
--check-only, wall time and peak memory:The walk was 40% of the boss demo's check time. In the other demos it is under 20 ms, so this is a large-program cost. Skipping the annotations would halve the walk again, but a dependency carried only by a constructor's field type would then be missed, so they stay.
bun gates/repo.tsis PASS: 46 / 46.tscoverbend2/packreports nothing in main.ts. The cluster gates were not run from here.Found while reviewing #936: this walk was about half of that PR's gain, and it is independent of how a literal is represented.
🤖 Generated with Claude Code