Skip to content

Give plugin errors W codes and module resolution M036 (#1968) - #2032

Merged
shunichironomura merged 1 commit into
mainfrom
fix-diagnostic-code-collisions-1968
Oct 10, 2026
Merged

shunichironomura merged 1 commit into
mainfrom
fix-diagnostic-code-collisions-1968

Conversation

@shunichironomura

Copy link
Copy Markdown
Member

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Summary

Fixes #1968: several stable diagnostic codes were each assigned to two different errors.

  • Plugin errors move from P0nn to W0nn (numbers kept, whole family including P010). P stays with parse errors, which are older and more numerous.
  • ModuleError::ModuleResolution moves from M033 to M036. LoadError::FileRootSelfImport keeps M033, since it was assigned first (Reject file-root self-imports #1532); the collision came in with Give compile-time diagnostics their own codes and typed payloads (follow-up S14–S15) #1933.
  • New workspace guard crates/graphcal-project/tests/diagnostic_codes.rs: discovers every code assignment in non-test sources across crates/*/src (code() arms, miette code(...) attributes, CODE constants) and asserts each code has exactly one site and each file uses one prefix. New error enums are covered without registration. Verified it fails on the reintroduced M033 collision. The compiler-only uniqueness loop is removed; its pinned-code test also pins M036, W001, W010.
  • Regenerated CLI output goldens and insta snapshots (code strings only), updated one LSP assertion, plugin-code comments, and the reading guide.
  • Docs (en/ja): extern-functions.md cites the W codes. authoring-plugins.md said P005/P016; the bare-binding rule actually reports InvalidExternSignature, so it now says W001/P016.

Out of scope: LSP-emitted literal codes (A001, and the deliberate E001 reuse) are not enum definitions and are not scanned.

AI assistance

  • AI used: yes — Claude Code investigated the issue, implemented the change, and ran just lint / just test.
  • Human review of AI-assisted code: pending

Breaking changes

  • No breaking changes
  • Breaking changes; the breaking change label is applied

Plugin errors shared P001-P011 with parse errors, and ModuleError::ModuleResolution
shared M033 with LoadError::FileRootSelfImport. Move the whole plugin family to
the W prefix (keeping numbers) and ModuleResolution, the later assignment, to M036.

Replace the compiler-only uniqueness check with a workspace test that discovers
every code assignment (code() arms, miette attributes, CODE constants) in
non-test sources, so new error enums are covered without registration.

Update docs citing plugin codes; authoring-plugins now cites W001
(InvalidExternSignature) for the bare-binding rule instead of P005.
@shunichironomura
shunichironomura merged commit 79ac945 into main Oct 10, 2026
47 checks passed
@shunichironomura
shunichironomura deleted the fix-diagnostic-code-collisions-1968 branch October 10, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: diagnostic codes P001–P007, P009, P011 and M033 are each assigned to two different errors

1 participant