c-expr-dsl-0.2.0.0: CHANGELOG.md
# Revision history for `c-expr-dsl`
## 0.2.0.0 -- 2026-10-06
### Breaking changes
* `parseMacro` is replaced by `parseMacroBody`, which parses a macro *body*.
Splitting a `#define` into its name, formal parameter list and body is now
the caller's responsibility. The formal parameters are passed in source
order, and references to them in the body become `LocalParam`s.
`parseMacroBody` consumes the entire token stream (it ends with `eof`).
See [issue #2243][issue-2243].
* `parseMacroType` likewise takes its formal parameters in source order.
* `Token`, `MultiLoc`, and `SingleLoc` from `libclang-bindings` are now
parameterized by a path type. All uses in `c-expr-dsl` apply `SourcePath`,
e.g. `Token SourcePath TokenSpelling` where `Token TokenSpelling` appeared
before. This follows the upstream `libclang-bindings` change that distinguishes
raw clang paths (`SourcePath`) from canonical on-disk paths (`RealPath`).
* Require `libclang-bindings` `>=0.2 && <0.3`, the release that contains the
path-parameterized types above.
### Bug fixes
* `runParser` no longer panics when given an empty token list; it returns a
`MacroParseError` instead. An empty macro body (`#define FOO`) is legal C and
may reach the parser. See [issue #2246][issue-2246].
* A formal parameter spelled like a keyword is now recognized as the parameter.
The preprocessor works on pp-tokens, which have no keywords. That is,
`#define F(bool) bool` is valid C and its body is the parameter. The parse no
longer depends on how libclang classifies the spelling, which varies with the
C standard: `#define F(bool) bool` used to yield the type `bool` under C23,
and a parameter named `const` or `sizeof` used to fail to parse.
* The shadowing above now also holds in qualifier, specifier and tag position,
where a token is matched by its spelling rather than looked up in the
parameter scope. `#define F(const) const x` used to parse as the type
`const x`, dropping the parameter; it is now rejected, since a qualifier
applied to a parameter has no representation. Likewise
`#define F(int) unsigned int` and `#define F(Foo) struct Foo`. Conversely
`#define F(const) const *` is now accepted as a pointer to the parameter.
[issue-2243]: https://github.com/well-typed/hs-bindgen/issues/2243
[issue-2246]: https://github.com/well-typed/hs-bindgen/issues/2246
## 0.1.0.1 -- 2026-07-22
### Bug fixes
* Add a file, which is required by the test suite, to the tarball.
## 0.1.0.0 -- 2026-07-14
### Breaking changes
* `CheckedMacroTypeExpr` is renamed to `TypecheckedMacroTypeExpr` and gains
`Foldable` and `Traversable` instances.
* `CheckedMacroValueExpr` is renamed to `TypecheckedMacroValueExpr` and gains
`Functor`, `Foldable`, and `Traversable` instances.
* `TypeSource` is renamed to `CTypeSource`; its constructors `TypeSourceTypedef`
and `TypeSourceMacroType` are renamed to `FromTypedef` and `FromMacroType`.
* Re-export parse-related symbols from `C.Expr.Parse`; demote lower-level
modules to `other-modules`.
* Re-export typecheck-related symbols from `C.Expr.Typecheck`; demote
`C.Expr.Typecheck.Expr` to `other-modules`; `C.Expr.Typecheck.Type` is still
an exposed module.
* `Expr` and `Term` gain a `ctx :: Ctx` type index (from `debruijn`) for
the local macro parameter scope. `Macro.macroArgs :: [Name]` is replaced
by an existential `macroParams :: Vec ctx Name`; `macroExpr` becomes
`Expr ctx Ps`. `sameMacro` compares macros structurally, ignoring location.
* `TypeTagged !TagKind !Name` is now a separate `Literal` constructor
instead of a `TypeLit` variant.
* Some macros that were previously erroneously parsed as function-like are now
parsed as object-like. See [PR #1990][pr-1990].
* Remove the `sameMacro` function. See [PR #1983][pr-1983].
* `CharLiteral.charLiteralValue` is now `CChar`; multi-character constants and
numeric escapes wider than a single byte are rejected during parsing.
* `StringLiteral.stringLiteralValue` is now a strict `ByteString` holding the
UTF-8 execution-encoding bytes (previously `[CharValue]`, then `ByteArray`).
* Rename `C.Expr.Syntax.Literals` to `C.Expr.Syntax.Literal`.
* Rename `Name` to `Identifier` (module `C.Expr.Syntax.Identifier`). The new
`Name` (module `C.Expr.Syntax.Name`) distinguishes ordinary names
(`NameOrdinary`) from tagged-type names (`NameTagged Identifier TagKind`).
Tagged types now parse as `Var` nodes rather than `TypeTagged` literals.
* The `Ps` pass gains an annotation type parameter (`Ps ann`); `XVar (Ps ann)`
carries a per-variable annotation. The `Tc` pass fixes its annotation to
`Maybe QuantTy`.
* `tcMacros` no longer takes a typedef set or the `injectType`, `injectValue`,
and `injectTaggedType` callbacks. It now takes a single
`ann -> Maybe QuantTy` projection mapping each variable's parse annotation to
its type (`Nothing` falls back to previously-typechecked macros). Accordingly,
`CTypeSource`, `buildTypedefEnv`, and the `MacroTcInjectError` result
constructor are removed.
### New features
* Parse macro types in addition to expressions; defer the type-vs-value
distinction to the typechecking phase. See [PR #1862][pr-1862].
* Add test suite covering the parser (token-based and real-world libclang
tests) and the typechecker. See [PR #1862][pr-1862].
* Local macro parameters in function-like macros are resolved to de Bruijn
indices (`LocalParam (Idx ctx)`) at parse time, distinguishing them from
free variables (`Var`).
* `tcMacro` now rejects type-like macros that expand to an incomplete type
(`void` or `const void` at the top level) with a new `TcIncompleteTypeMacro`
error. Pointer-to-incomplete types (e.g. `void *`) are still accepted.
* Support multi-line macro definitions. See [PR #1993][pr-1993].
### Minor changes
* New unit test suite `Test.CExpr.Parse.Literal` covering all character and
string literal forms, escape sequences, and rejection cases.
### Bug fixes
* In accordance with the C reference, parse macros only as function-like when
there is no whitespace between the macro name and the opening parenthesis of
the parameter list. See [PR #1990][pr-1990].
[pr-1862]: https://github.com/well-typed/hs-bindgen/pull/1862
[pr-1983]: https://github.com/well-typed/hs-bindgen/pull/1983
[pr-1990]: https://github.com/well-typed/hs-bindgen/pull/1990
[pr-1993]: https://github.com/well-typed/hs-bindgen/pull/1993
## 0.1.0-alpha -- 2026-02-06
* Release candidate.