Typecheck the whole workspace so make and the editor agree - #3
Conversation
|
Im not sure we need all of the added comments. Re-review with emphasis on if these comments you added are adding value |
|
Re-reviewed at Delete: the
|
derek-miller
left a comment
There was a problem hiding this comment.
Requesting changes on two counts. The scope diagnosis is right, and measuring that my suggested fix alone would have regressed to 57 problems is a good catch, so the direction is not in question.
1. The numbers do not reproduce, and make typecheck fails
Same machine, same lua-language-server 3.18.2-dev, run back to back:
main, --check src Found 11 problems in 3 files
FL-4, --check $(CURDIR) Found 18 problems in 4 files (make exits 1)
The PR states this "lands on 11 problems, identical to the previous baseline". Here it is 18. Per file:
8 src/crypto/aes_gcm.lua
6 vendor/bitn.lua
2 src/crypto/srp.lua
2 src/crypto/ed25519.lua
Two things follow. vendor/bitn.lua contributes 6 of its own, which contradicts "vendor/bitn.lua contributes nothing of its own". And aes_gcm went from 6 to 8 without its scope changing, so this is not a pure scope delta.
Most likely a different language server version on your side. Either way, pin the version in the target or note it in CLAUDE.md: a check whose baseline moves with the tool cannot be "identical to the previous baseline" for anyone else, and this is the second time a stated number has not held on my machine.
Tests and lint are fine: 15/15 modules, and make lint reports 0 warnings / 0 errors across 20 files, which covers the leg you could not run locally.
2. Comment volume
14 lines of comment for a one-word change in the Makefile, and a 5-line note in annotations.lua explaining an absence. Both make the same point three times.
Makefile, replacing the 7 added lines:
# Checks the whole repo, not just src/: an editor's workspace is the repo, and
# @alias resolves workspace-wide, so a narrower scope gives different findings
# rather than fewer.
annotations.lua, replacing the 5-line block:
-- Int64HighLow is defined in vendor/bitn.lua, where these halves come from.
This is a pattern across recent PRs rather than a one-off: the explanation often runs longer than the change and restates itself. One sentence for the non-obvious reason, then stop.
|
Following up on the count discrepancy, because I found the cause and it also answers "keep vendor's type defs, drop its diagnostics". The mechanism
All 11 are in Why the numbers disagreed
So Incidentally this also corrects the PR body: Suggested shapeCommit a config for the check and point the target at it, leaving lua-language-server --check "$(CURDIR)" --checklevel=Warning \
--configpath="$(CURDIR)/.luarc-typecheck.json" --logpath="$(CURDIR)/build/luals"{
"runtime": { "version": "LuaJIT" },
"workspace": {
"useGitIgnore": false,
"library": ["vendor"],
"ignoreDir": [".claude", ".git", ".idea", ".venv", "build", "dist", "node_modules", "vendor"]
},
"diagnostics": { "disable": ["unnecessary-assert"] }
}Verified with |
`Int64HighLow` was defined in both `src/crypto/annotations.lua` and `vendor/bitn.lua`, so an editor with the repository open reported `duplicate-doc-alias` on each while `make typecheck` saw neither. Dropping the duplicate on its own regresses the check. `typecheck` ran `--check "$(CURDIR)/src"`, which never scans `vendor/`, so removing the alias from annotations.lua takes the run from 11 problems to 57: the 46 `undefined-doc-name` reports that annotations.lua was added to eliminate. The duplicate is a symptom; the scope mismatch is the cause. An editor opens the repository as its workspace, and `@alias` resolves workspace-wide, so a narrower scope does not yield a subset of the findings, it yields a different set. Widening the scope alone still leaves the count unreproducible, because `.luarc.json` is matched by a global gitignore and has never been in the repository, so the target read whichever private config the developer happened to have. `runtime.version` is what moved the number: unset it defaults to Lua 5.4 and `vendor/bitn.lua` is clean, while `LuaJIT`, the runtime this library actually targets, reports 7 of its own. So the config is committed and the target pins it with `--configpath`, leaving `.luarc.json` as personal editor preference. `vendor` is listed as a `workspace.library` and in `ignoreDir`: as a library its `@alias` definitions still resolve, and via ignoreDir its files are not diagnosed. Either half alone is wrong (ignoreDir without library loses the definitions and returns to 57; library without ignoreDir reports 18). 11 problems in 3 files, all in src/, reproducible regardless of any local .luarc.json, on lua-language-server 3.19.0 The target now prints the server version, because the remaining 11 are tool-version sensitive. Verified: `make typecheck` 11 problems in 3 files, the same param-type-mismatch set as the previous baseline; `./run_tests.sh` 15/15 modules; `make format-check` clean. `make lint` was not runnable here (luacheck 1.2.0 fails under this host's Lua 5.5, in its own standards.lua); CI's luacheck leg is unaffected. FL-4
b018dc6 to
9245a39
Compare
|
Pushed as One correction to the mechanism, because it changes what the config is doing. The cause is
|
derek-miller
left a comment
There was a problem hiding this comment.
Approving 9245a39. Verified on 3.18.2-dev: make typecheck 11 problems in 3 files, matching your number; 15/15 modules; make lint 0 warnings / 0 errors across 20 files; make format-check and make build clean. Comments are down to four lines and one line.
unnecessary-assert is inert on 3.18.2-dev too. 11 problems either way and no such diagnostic is emitted, so it is not load-bearing on the older server. Drop it.
The runtime.version isolation is the better diagnosis and it corrects mine. I said the count moved because the config was untracked; the actual variable was that an absent runtime.version defaults to Lua 5.4, so round 1 type-checked a LuaJIT/Control4 library as 5.4. Making the version explicit in the committed config is what makes any of these numbers mean anything, and it turns library + ignoreDir into a real requirement rather than tidiness.
You are also right that !.luarc.json in the repo's .gitignore would override core.excludesFile. My "cannot by adding a repo rule" was wrong. The split you shipped is still the one I would pick, since it separates editor preference from what the check pins.
|
Post-merge One correction to what landed, since the squash body is The per-file disagreement in this thread was one run counted three ways, not two tools: The last is your tally, and I reproduced it exactly by grepping that way before I checked myself. The pretty stream is not safely countable: the progress bar shares its line with the next diagnostic, so a line-anchored count drops one per batch, and So the version print is harmless but treats a non-cause, and the worry behind your review point retires rather than staying open: it is 11 in 3 files on your version too, verified on the 3.18.2-dev binary rather than inferred. On the open question from the last round: Also re-checked on the merged tree, independently of the round-2 comment: |
…onfig (#4) The key was carried over from the config proposed in the #3 review on the assumption it was load-bearing on lua-language-server 3.18.2-dev. It is not: the review confirmed 11 problems either way there, with no such diagnostic emitted, and 3.19.0 agrees. A disabled diagnostic that never fires reads as a known exception to anyone changing this file later, so it is worse than nothing. Verified: `make typecheck` 11 problems in 3 files, unchanged; 15/15 modules; `make format-check` clean.
Follow-up to the non-blocking item in the #2 review:
Int64HighLowdefined twice, insrc/crypto/annotations.lua:32andvendor/bitn.lua:1742, reported asduplicate-doc-aliasby an editor but invisible tomake typecheck.The suggested fix alone would have regressed the check
The review suggested dropping the alias from annotations.lua and letting bitn's stand.
--check "$(CURDIR)/src"never scansvendor/, so removing the alias put bitn's definition out of scope and reinstated the 46undefined-doc-namereports that annotations.lua exists to eliminate: 11 problems to 57.So the duplicate is a symptom and the scope is the cause
An editor opens the repository as its workspace; the target scoped itself to
src/.@aliasresolves workspace-wide, so a narrower scope does not give a subset of the findings, it gives a different set: that is exactly why one of us saw the duplicate and the other did not.Widening the scope alone is not reproducible
Round 1 reported 11 problems, the review measured 18 on the same branch.
runtime.versionis the whole of that gap, and.luarc.jsonis where it was set:runtime.versionLuaJITLua 5.1.luarc.jsonis matched by a global gitignore, so it has never been in the repository and the target read whichever private config the developer happened to have. Round 1's config had noruntime.versionand checked this library as Lua 5.4;LuaJITis what it actually targets, and under itvendor/bitn.luareports 7 of its own.The fix
.luarc-typecheck.jsonis committed and the target pins it with--configpath, leaving.luarc.jsonas personal editor preference.vendoris listed both as aworkspace.libraryand inignoreDir: as a library its@aliasdefinitions still resolve, and via ignoreDir its files are not diagnosed. Both halves are load-bearing:ignoreDirwithoutlibraryundefined-doc-namereturns)librarywithoutignoreDirsrc/No
undefined-doc-nameand noduplicate-doc-alias, soInt64HighLowstill resolves fromvendor/bitn.luawith the alias dropped from annotations.lua.Verification
On lua-language-server 3.19.0. The target now prints the server version, because the remaining 11 are tool-version sensitive.
make typecheck: 11 problems in 3 files (aes_gcm5,ed255193,srp3), the sameparam-type-mismatchset as before, and unchanged with a deliberately conflicting.luarc.jsonplanted in the working tree./run_tests.sh: 15/15 modules passmake format-check: cleanmake typecheckexits non-zero whenever it reports anything, onmainas well as here, which is why it is not part ofcheck.Not verified locally:
make lint. luacheck 1.2.0 fails under this host's Lua 5.5 (attempt to assign to const variable 'field_name'in its ownstandards.lua), which is an environment problem rather than a repo one. CI's luacheck leg covers it.FL-4