Skip to content

docs: checklist for adding or changing a .cabal file format field - #12056

Open
andreabedini wants to merge 1 commit into
haskell:masterfrom
andreabedini:docs/cabal-format-field-checklist
Open

docs: checklist for adding or changing a .cabal file format field#12056
andreabedini wants to merge 1 commit into
haskell:masterfrom
andreabedini:docs/cabal-format-field-checklist

Conversation

@andreabedini

@andreabedini andreabedini commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a new section to CONTRIBUTING.md, "Adding or changing a .cabal file format field", documenting how to correctly gate new or changed .cabal fields behind cabal-version.

This is the class of bug described in #9331: when a new field is not gated, an older Cabal/cabal-install silently accepts it and does the wrong thing, or a newer field leaks into a package that claims an old cabal-version. Features that influence generated files (Paths_*.hs, cabal_macros.h, autogen sources, …) are especially dangerous when ungated.

I tried to be as clear as possible, please review and suggest changes.

What it documents

A step-by-step checklist around the CabalSpecVersion enum:

  1. Ensure a CabalSpecVersion constructor exists for the next unreleased (even) spec version — and that adding one is an API-breaking change requiring a major version bump, with the total functions that must be extended.
  2. Bump cabalSpecLatest in the same change, so the constructor and cabalSpecLatest never drift apart.
  3. Gate the field in FieldGrammar.hs with availableSince <literal constructor> []not the name cabalSpecLatest, which would retroactively move the field's introduction version forward on every spec bump.
  4. Add the matching checkSpecVer in Cabal/.../Check/Target.hs so cabal check reports the field used below its introduction version.
  5. Document the change in doc/file-format-changelog.rst and add a changelog.d/ entry.

Type of change

Documentation only — no code changes, no changelog entry required.

Copilot AI review requested due to automatic review settings June 29, 2026 02:49
@andreabedini
andreabedini requested review from Mikolaj and ffaf1 June 29, 2026 02:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new CONTRIBUTING guide section describing the required workflow for introducing or changing .cabal file format fields, with a focus on correctly gating syntax behind cabal-version (and ensuring cabal check enforces the introduction version) to prevent issues like #9331.

Changes:

  • Documented a step-by-step checklist for adding/changing .cabal fields, centered on CabalSpecVersion and cabalSpecLatest.
  • Documented the correct way to gate fields in FieldGrammar.hs (and why not to use cabalSpecLatest by name).
  • Documented adding the corresponding checkSpecVer enforcement in Cabal/.../Check/Target.hs, plus changelog updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md
@Mikolaj

Mikolaj commented Jul 22, 2026

Copy link
Copy Markdown
Member

@andreabedini: do you think the Copilot's comments are worth answering? Ideally, I'd not review while the PR is in the middle of other changes.

@andreabedini
andreabedini force-pushed the docs/cabal-format-field-checklist branch from 9e897eb to e09e04c Compare August 11, 2026 04:55
Add a 'Adding or changing a `.cabal` file format field' section explaining how
to gate new fields behind `cabal-version` to avoid the haskell#9331 class of bug where
ungated fields are silently accepted by older Cabal.

The checklist covers the full mechanism around `CabalSpecVersion`: ensuring a
constructor exists for the next unreleased spec version (a major API break),
keeping `cabalSpecLatest` in sync, gating the field in `FieldGrammar.hs` with a
literal `availableSince` constructor (not the name `cabalSpecLatest`), adding a
matching `checkSpecVer` in `Check/Target.hs`, and documenting the change.
@andreabedini
andreabedini force-pushed the docs/cabal-format-field-checklist branch from e09e04c to e183fc0 Compare August 11, 2026 04:58
@andreabedini

Copy link
Copy Markdown
Collaborator Author

@Mikolaj I believe the comments have been addressed.

@Mikolaj Mikolaj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andreabedini
andreabedini requested a review from angerman August 17, 2026 09:13

@angerman angerman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that AIs (if they end up being used) find this helpful as well! Or hold their meat proxies to this checklist!

@andreabedini andreabedini added merge me Tell Mergify Bot to merge and removed attention: needs-review labels Aug 17, 2026
@mergify mergify Bot added the ready and waiting Mergify is waiting out the cooldown period label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge me Tell Mergify Bot to merge ready and waiting Mergify is waiting out the cooldown period

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants