fix(check): read the ~ operator sites the parser records instead of walking the tree - #566
Merged
Merged
Conversation
…alking the tree Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Merged
6 tasks
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.
What and why
UndefinedOperatorPassfound every~xby runningast.Inspect, a reflection-based walk over every node of every document, on each analysis. A CPU profile ofBenchmarkLoadModel/elements=1000put that walk at 7.6% of total load time, about 40% of the validate slowdown against 0.8.1, for a warning that almost never fires.The parser is the one place that builds an
OpBitNotexpression (parseUnary), so it now records those sites and the pass reads the list:Parser.undefinedOpsis appended inparseUnary;parseCheckpointcarries its length andrestoretruncates it, so an abandoned try-parse leaves nothing behind;ParseFilehands the list to the root.astcodecencodes/decodes the field forRootNamespace(typed pointer slice, same pattern asregions/ends), so the on-disk index cache keeps it. The embeddedstdlib.snapshotis regenerated for the format change.UndefinedOperatorPass.Runiteratesroot.UndefinedOperators; level, code and message are unchanged.ast.Inspectstays: the export tests, hygiene tests and the doc-counts census still use it.BenchmarkLoadModel/elements=1000(-benchtime 20x, -count 3): develop 108.2/111.8/120.8 ms → 103.2/103.3/106.6 ms, about 7% faster.How it was verified
TestUndefinedOperators*ininternal/syntax/parser: source order, nested~~x, positions inside calc bodies and invocation arguments.tests/parserfixtureundefined-operator.sysml(golden added) andTestUndefinedOperatorsCoversFixtures, which parses every parse fixture and checks the recorded list against an independent reflective count ofOpBitNotnodes.undefined_operator_test.gopasses unchanged; astcodec round-trip/sharing tests pass.gofmt -l .empty,go build ./...,go vet ./...,go test ./internal/syntax/... ./internal/check/... ./tests/parser ./internal/workspace/...,TestStdlibConformance,python3 scripts/changelog.py check.Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelog