Repository navigation
Place facts where they are written: origins read path:line:column (Make, CMake, Meson, Cabal, shell scripts, YAML) - #362
Merged
Conversation
`Choices`, `assigned` and `combined` (a variable's values set in branches, each in the builds it takes it in) were written for Meson's values, but nothing in them is Meson's. They move to `facts.conditions`, generic over the value, so that Make's evaluator can keep its variables the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Makefiles indent what a conditional holds (neovim's ` CMAKE := cmake` under `ifeq ($(UNIX_LIKE),FALSE)`). Only a tab starts a recipe line; make reads any other line as if it were not indented. The parser matched assignments, includes and rules from the line's first column, so an indented one was read as a directive and never set: neovim's CMAKE was unknown in every recipe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…lds in Make read a conditional it could not decide by reading every branch, one after another. A variable set in two branches kept only the last value, and every recipe line ran on every runner: a Linux job "ran" the Windows branch's `build.bat`, and `$(RM)` was `rm -f` on Windows too. The evaluator now reads each line in the builds it holds in, a `Condition`, as Meson's and CMake's do: - A conditional's test is a `Condition`. A test the makefile and the command line decide takes its branch, as before. One on the platform (`$(OS)` is Windows_NT, or empty; what `$(shell uname -s)` prints, also through `UNAME_S := $(shell uname -s)`) holds on those platforms. Anything else the environment could decide (`ifdef DEBUG`, `ifeq ($(CC),clang)`) holds behind that requirement, so both branches may still run. - A variable holds each value in the builds its assignment was read in (`=`, `?=`, `+=` alike), and a recipe line expands to each text its variables give it, in the builds it takes it in. Prerequisites carry their builds too. - A recipe line that holds in only some builds is an `expansion.Only`. A CI job follows it only where it may hold on the job's runner; on a runner of unknown OS, everywhere. An unknown recipe in a branch that cannot hold there is not reported, and one whose program is unknown is reported once, whatever values its arguments take. Expansion is now recursive, which fixes how a variable that refers to itself was read: argo-cd's `BUILD_DATE := $(if $(BUILD_DATE),$(BUILD_DATE),…)` was substituted ten times over, doubling each time, into a 375 kB argument. A reference inside its own variable's value now stays as written (make rejects a variable that refers to itself). A reference whose name is computed (erlang.mk's `$(gen_verbose_$(V))`) is still expanded once its name is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
A fact's origin could hold where in the file it was found (a span), but it read the same without one: only the structured place (`jobs.test.steps[3].run`). With a span it now reads as compilers write a position, so that an editor or terminal opens the file there, followed by the place when there is one: `Makefile:40:1 (check)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
A recipe's origin named its line inside the place (`Makefile:check[40]`). It is the recipe line's span now, `Makefile:40:1 (check)`, with its end, as the tree has it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
A CMake invocation knew only its line, and a fact's origin named it inside the place (`CMakeLists.txt:set[12]`). An invocation now spans from its name to past its closing parenthesis, and every fact made from it is placed there: `CMakeLists.txt:12:3 (set)`. That includes those that held only the file's path: CTest settings, guards (`if(PROJECT_IS_TOP_LEVEL)`) and declared dependency managers. Two declarations of one manager in a file are now two facts, one at each. A file CMake could not evaluate (a syntax error, the nesting limit passed) is unknown where it went wrong, when that is known: the error's line, or the include, subdirectory or call that went past the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Meson's tokens knew only their line, and a fact's origin named it inside the place (`meson.build:project[1]`). Tokens now have spans, and a statement spans from its first token to its last: facts are placed there (`meson.build:3:3 (add_project_arguments)`). Guards and tests held only the file's path. A test is now placed at its `test()`, and a guard at its own `if` or `elif`, through its condition: the frame they were made in still held the line of the statement before. A file that does not parse is unknown at the error's line. `Problem`, a reason and where, moves to `parsing` for CMake and Meson to share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
The Cabal tree knew each section's line but not where its fields were, so a `ghc-options` value could not be placed: its facts held only the file's path. A field now spans from its name to the end of its last continuation line, and a section's header has a span: GHC's options are placed at their field (`app.cabal:17:3 (ghc-options)`), and a test suite at its stanza (`app.cabal:27:1 (test-suite)`). Options from Stack's and hpack's YAML stay at the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
The shell tree knew where each command was, but the commands it gave did not keep it. A command now carries its span, and the commands of a script file the project holds (`./ci/build.sh`), whose text is the file's, are placed there: `ci/build.sh:4:3`. A CI step's own script is a block inside the workflow, so its commands keep the step's place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #362 +/- ##
==========================================
+ Coverage 99.68% 99.72% +0.03%
==========================================
Files 311 312 +1
Lines 19734 19950 +216
Branches 2303 2333 +30
==========================================
+ Hits 19672 19895 +223
+ Misses 62 55 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…as them A CI file's facts named their place by its keys (`ci.yml:jobs.test.steps[3].run`), but the YAML loader kept no positions, so none was placed. `yaml_support.places` composes the document (PyYAML keeps marks on its nodes) and answers where each place is: a key from itself through its value, a sequence's item from its start to its end, and a key a mapping merges in (`<<: *defaults`) where it is written. Facts are placed as the CI commands stage yields them (`facts.placed.Placed`), each in the file its origin names: the CI file, a file a GitLab pipeline includes, a composite action, a pre-commit configuration, and the commands that ran a command (`via`). `ci.yml:14:9 (jobs.test.steps[3].run)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
A tool's YAML settings (clang-tidy, golangci-lint, RuboCop, buf, detekt, SwiftLint, molecule) named their place by their dotted key under the reader's prefix. Each is placed where the file has that key (`molecule.yml:2:3 (name)`). A key with a dot in it does not name a place the file has, and is left at the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
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.
Part of #300 (acceptance: "messages and
--explaingivepath:line:columnwherever the source position is known")Merge after #360. This PR is built on its Make changes, so until #360 merges, this diff also shows its commits.
What changes
Every syntax tree has spans, but almost no fact kept one in its
Origin(only tool settings that don't parse), and anOriginnever showed it. An origin with a span now reads the way compilers write a position, followed by its place when it has one:Makefile:check[40]Makefile:40:1 (check)CMakeLists.txt:add_compile_options[16]CMakeLists.txt:16:1 (add_compile_options)CMakeLists.txt(CTest settings, guards, dependency managers)CMakeLists.txt:3:1 (enable_testing)meson.build:project[1], and the file only for guards and testsmeson.build:1:1 (project),meson.build:5:1 (elif)app.cabalapp.cabal:17:3 (ghc-options),app.cabal:27:1 (test-suite)ci/build.shci/build.sh:4:3.github/workflows/ci.yml:jobs.test.steps[3].run.github/workflows/ci.yml:14:9 (jobs.test.steps[3].run).clang-tidy:WarningsAsErrors.clang-tidy:2:1 (WarningsAsErrors)Editors and terminals open the file at that place.
By reader, one commit each
if/elif. Before, they took the line of whatever statement came before them.test().Script.whole) the text is the file, so its commands are placed there. A CI step'srun:block keeps the step's place, since its spans are relative to the block.yaml_support.placescomposes the document (PyYAML keeps marks on its nodes) and finds where each place is. A key spans from itself through its value, an item from its start to its end, and a key a mapping merges in (<<: *defaults) is placed where it is written.facts.placed.Placed), each in the file its origin names: the CI file, a file a GitLab pipeline includes, a composite action, a pre-commit configuration, and the commands that ran a command (via).Problem(a reason and where it is) moves toparsing, shared by CMake and Meson.One visible side effect
Facts that only looked equal because their origins had no position are now separate. Two
if(MSVC)guards, or two FetchContent declarations in one file, are two facts, one at each line. Thewell_configured_c/_cppsnapshots list the second declaration.Not covered
jsonandtomllibkeep no positions, so these stay at the file.Verified
(Makefile:bootstrap[27])→(Makefile:27:1 (bootstrap)),(configure)→(configure:157:19),(…/ci.yml:jobs.x.steps[2].run)→(…/ci.yml:31:9 (jobs.x.steps[2].run))).🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt