What a generated type promises that the type itself cannot say - #46
Merged
Conversation
The exemplar's first two sections each end with two static_asserts, and both acceptance tests stripped them. The document recorded that as an open question: they are an assertion about a generated type rather than something the schema asked for, and where they belong was undecided. They belong in the AST, and the decision turns on something already settled. SourceFile.Imports are the one part of the AST that does not translate -- a C++ include path, a C# namespace and a Python module are different kinds of thing that share a position, so each is carried as text for the language the file is for. A compile-time predicate is the same shape of problem: std::is_trivially_copyable_v<T> has no equivalent anywhere else, so there is no shared idea underneath it to model. CompileTimeAssertion.Condition is therefore text, which makes it consistent with an existing rule rather than a new special case. Only C++ has anything checked before the program runs. The other three write a comment saying what was asserted, because a file that quietly loses a guarantee looks exactly like one that still makes it. The message goes on its own line. These are long by nature -- the predicate says what is false and the message says why anyone cared -- and a compiler quoting the whole declaration back is easier to read as two lines than as one very wide one. Both acceptance tests now assert the document's sections in full. That is the point of this change: sections 1 and 2 are byte-identical to the specification rather than byte-identical to it less two lines each. Getting there needed the blank-line rule in one more place. A namespace and a file separated every member unconditionally, which split the two assertions about one type into two paragraphs. They now follow the same rule the members of a type do, hoisted to a virtual on the base: always separate, unless a language says otherwise, and C++ says two of a kind that say nothing about themselves stay together. 485 tests pass, 477 before and 8 new, with 0 warnings across the solution. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk
|
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.



The exemplar's first two sections each end with two
static_asserts, and both acceptance tests stripped them. The document recorded that as an open question — they are an assertion about a generated type rather than something the schema asked for, and where they belong was undecided.Both acceptance tests now assert the document's sections in full. That is the point of this change: §1 and §2 are byte-identical to the specification rather than byte-identical to it less two lines each.
Where they belong, and why
The decision turns on something already settled in this AST.
SourceFile.Importsare the one part that does not translate — a C++ include path, a C# namespace and a Python module are different kinds of thing that share a position, so each is carried as text for the language the file is for.A compile-time predicate is the same shape of problem.
std::is_trivially_copyable_v<T>has no equivalent anywhere else, so there is no shared idea underneath it to model.CompileTimeAssertion.Conditionis therefore text — which makes it consistent with an existing rule rather than a new special case.The message goes on its own line. These are long by nature — the predicate says what is false and the message says why anyone cared — and a compiler quoting the whole declaration back reads better as two lines than as one very wide one.
Only C++ has anything checked before the program runs. The other three write a comment saying what was asserted, because a file that quietly loses a guarantee looks exactly like one that still makes it:
// asserted at build time: std::is_standard_layout_v<RigidBody>One rule needed hoisting
A namespace and a file separated every member unconditionally, which split the two assertions about one type into two paragraphs. They now follow the same rule the members of a type already do, lifted to a virtual on the base:
So a struct is separated from the assertions about it, and those assertions are one block.
Verification
dotnet build -c Release— 0 warnings, 0 errors across the solutionThe new tests cover the C++ spelling with and without a message, escaping of a message containing a quote, what the other three languages say instead, the grouping rule, the YAML round trip, cloning, and placing one through the graph.
Each acceptance expectation is still rebuilt from the document's own text. The semantic type's remains the document with exactly one line substituted — the short accessor, which clang-format does not reconcile either way — and the test still names that substitution as the only one.
What is next
The bridge from a
ktsu.Schemamodel to these nodes. It is currently blocked onktsu.Coderpublishing a version containing the node set merged in #45: the newest on NuGet is 3.3.0, which predates that merge, and Schema would need to reference it.🤖 Generated with Claude Code
https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk
Generated by Claude Code