docs/.ai/skills/add-error-code-docs.md
Canonical skill for creating or updating Scala 3 error-code docs in
docs/_docs/reference/error-codes/.
This file is the single source of truth. Keep other related files as pointers.
project/scripts/checkErrorCodeSnippets.scala.NonReproducibleErrorCodes aligned in
project/scripts/checkErrorCodeSnippets.scala.Use this template for each E###.md page:
---
title: E###: <Short Title>
kind: Error
# since: 3.x.y # required when code > E166
# until: 3.x.y # required when the compiler ID is inactive
---
# E###: <Short Title>
<Explain when this diagnostic happens and why.>
## Example
```scala sc:fail sc-opts:-explain
<minimal snippet that triggers only E###>
```
### Error
```scala sc:nocompile
-- [E###] <Error|Warning>: example.scala:<line>:<col> -------------------------
<exact checker output here, including explanation text when present>
```
### Solution
```scala sc:compile
<direct fix of the example above>
```
<!-- SOURCE-ONLY: Remove the notice below once this page has been manually updated. -->
<aside class="warning">
This reference page was created with LLM assistance - the description of the error code may not be accurate or cover all possible scenarios.
</aside>
For warning diagnostics, normally make the example fail under -Werror:
<warning-producing snippet>
compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala.docs/_docs/reference/error-codes/E###.md.title and kind (Error or Warning).since when errorNumber > 166.until when the ID is inactive.## Example, ### Error or ### Warning, ### Solution.sc:fail (or custom-sc:fail only when required).sc:nocompile.sc:compile (or custom-sc:compile only when required).sc-opts:-explain, sc-opts:-Werror, etc.).[E###].docs/sidebar.yml under Error Codes in numeric order.From repository root:
DOC=docs/_docs/reference/error-codes/E###.md
One-time local compiler setup (rerun only when artifacts/version change):
sbtn scala3-bootstrapped/publishLocal
Cache local bootstrapped version:
VERSION_CACHE=/tmp/scala3-bootstrapped-version.txt
version=$(BOOTSTRAPPED_VERSION_CACHE="$VERSION_CACHE" project/scripts/get-bootstrapped-version.sh --refresh)
# later runs:
# version=$(BOOTSTRAPPED_VERSION_CACHE="$VERSION_CACHE" project/scripts/get-bootstrapped-version.sh)
Refresh ### Error / ### Warning output:
scala --server=false --scala-version "$version" \
project/scripts/checkErrorCodeSnippets.scala -- "$DOC" --update-output
Run full validation:
scala --server=false --scala-version "$version" \
project/scripts/checkErrorCodeSnippets.scala -- "$DOC" --verbose
Expected guarantees when validation runs:
E###.-Werror enforced by checker).E###.