Include the error enum in a header that names it - #199
Merged
Merged
Conversation
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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



A generated interface header named
Result<T, ErrorCode>and included nothing that declaresErrorCode. 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:
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,ObjectorInterface, and each of those goes throughGenerated, 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 ofSchema.ErrorTypeexisting.MapResultbuilt it as a bareTypeReference: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
Generatedis 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.
TheHeaderIncludesTheErrorEnumItNamesasserts the#includeis in the interface header itself, which is the property that makes the header stand alone.GeneratesTheInterfaceTheDocumentSpecifiespinned 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
Schema.Cpp.Test, 476/476 inSchema.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