Skip to content

Include the error enum in a header that names it - #199

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/blissful-euler-fzuap2
Sep 15, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/blissful-euler-fzuap2

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

A generated interface header named Result<T, ErrorCode> and included nothing that declares ErrorCode. It compiled only where something else had already included that enum first.

Holotype hit it the moment a test included the interface header on its own:

PhysicsWorld.gen.hpp:37: error: 'PhysicsError' was not declared in this scope;
                               did you mean 'PhysicsWorld'?

Why this one and not the others

The error type is the one named type a signature reaches without the schema's type vocabulary naming it. Every other name in a generated header arrives through Enum, Object or Interface, and each of those goes through Generated, which requires the include on the way past. The error comes off the schema root instead — because what a failure says is global rather than per-signature, which is the whole point of Schema.ErrorType existing.

MapResult built it as a bare TypeReference:

outcome.TypeArguments.Add(new TypeReference(schema.ErrorType.ToString()));

That is the one path to a generated name that skips the include, and the asymmetry is exactly why it was the one that was missed. Routing it through Generated is the whole fix.

Why the test asserts on the include rather than on a compile

The acceptance tests generate a whole schema and compile the set, so the neighbouring class headers would have supplied the enum and the test would have passed on the accident being tested for. TheHeaderIncludesTheErrorEnumItNames asserts the #include is in the interface header itself, which is the property that makes the header stand alone.

GeneratesTheInterfaceTheDocumentSpecifies pinned the buggy output and is updated by exactly the one added line — it caught the change, which is what a golden file is for.

Verified

  • Reverted the fix and confirmed the new test fails, then restored it.
  • 103/103 in Schema.Cpp.Test, 476/476 in Schema.Test.

How it was found

Holotype's exemplar schema is the depth suite for this generator, and it had no interface in it — so nothing had ever compiled a generated interface header in isolation. Adding one (matt-edmondson/Holotype#33) surfaced this on the first build. The breadth suite could not have: the 26 migrated schemas declare no interfaces and no error type at all.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UGHDsYaaTQdzVR4XBR6miu


Generated by Claude Code

A generated interface header named `Result<T, ErrorCode>` and included
nothing declaring `ErrorCode`, so it compiled only where something else
had already included that enum first. Holotype hit it the moment a test
included the interface header on its own:

    PhysicsWorld.gen.hpp:37: error: 'PhysicsError' was not declared in
    this scope; did you mean 'PhysicsWorld'?

The error type is the one named type a signature reaches without the
schema's type vocabulary naming it. Every other name in a header arrives
through `Enum`, `Object` or `Interface` and takes its include along the
way through `Generated`; this one comes off the schema root, because what
a failure says is global rather than per-signature. `MapResult` built it
as a bare `TypeReference` instead, which is the one path that skips the
include -- and that asymmetry is exactly why it was the one that was
missed.

Routing it through `Generated` is the whole fix.

Asserted on the include rather than on a compile: the acceptance tests
generate a whole schema and compile the set, so the neighbouring class
headers would have supplied the enum and the test would have passed on
the accident being tested for. `GeneratesTheInterfaceTheDocumentSpecifies`
pinned the buggy output and is updated by exactly the one added line.

Verified by reverting the fix and watching the new test fail. 103/103 in
Schema.Cpp.Test, 476/476 in Schema.Test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UGHDsYaaTQdzVR4XBR6miu
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 55043bd into main Sep 15, 2026
13 checks passed
@matt-edmondson
matt-edmondson deleted the claude/blissful-euler-fzuap2 branch September 15, 2026 08:21
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.

2 participants