Skip to content

ppx_devtools.expect: fix tests in functors and attributes on sequences - #8

Merged
hhugo merged 1 commit into
mainfrom
expect-functor-and-sequence-attrs
Nov 16, 2026
Merged

hhugo merged 1 commit into
mainfrom
expect-functor-and-sequence-attrs

Conversation

@hhugo

@hhugo hhugo commented Nov 16, 2026

Copy link
Copy Markdown
Member

Two bugs found while looking for bugs in the expect ppx and its runtime.

A test in a functor applied more than once

Such a test is registered once per application, and each registration produced the same corrections, all of which were applied. Promotion wrote

[%expect {| a |} {| a |}];

which does not compile, and inserted a new trailing [%expect] twice. Identical corrections for a file are now applied once.

Not covered: when the instances print different outputs, the correction of one of them is still silently dropped.

Attributes on a sequence

A sequence in a test body is rebuilt by the ppx, which dropped its attributes: (raise Exit; ...) [@warning "-21"] lost its [@warning]. They are now kept. A nested sequence carrying attributes, as in a; ((b; c) [@attr]), is no longer flattened into the enclosing one, so an [%expect] in it is not grouped with [@when] variants outside of it.

Tests

Two cases added to test/promote: a functor applied twice, and a sequence that does not compile without its [@warning "-21"]. Native tests pass; the js and wasm aliases were not run locally.

🤖 Generated with Claude Code

- A test in a functor applied more than once is registered once per
  application, and each registration gave the same corrections: promotion
  wrote [%expect {| a |} {| a |}], and inserted a new [%expect] twice.
  Identical corrections are now applied once.
- The attributes of a sequence in a test body were dropped when the
  sequence was rebuilt, e.g. the [@warning "-21"] of
  [(raise Exit; ...) [@warning "-21"]]. They are now kept, and a nested
  sequence carrying attributes is left as a statement of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@hhugo
hhugo merged commit 8e9c2be into main Nov 16, 2026
13 checks passed
@hhugo
hhugo deleted the expect-functor-and-sequence-attrs branch November 16, 2026 23:42
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.

1 participant