State the strict-floor rule once, and pin it - #253
Merged
Merged
Conversation
Both readers of dimensions.json decided for themselves which
physicalConstraints value opts a V0 overload into the stricter floor, by
each carrying a copy of `MinExclusive == "0"`. The copies agree today.
They did not always: the C++ reader used to test the constraints object
for null instead, so an overload declaring `{}` or any floor other than
"0" would have been strictly positive in C++ and non-negative in C#, and
nothing would have caught it.
Move the rule into OverloadDeclaration.IsStrictFloor, which both readers
now ask rather than restate, and cover the cases that separate it from
the presence test: an empty constraints object, and a floor of some other
value. Both new cases fail against the old rule; the rest of the suite
does not, which is the gap.
The real metadata declares no such constraint yet, so these are driven by
a document written for the purpose -- the point is to fail on the day it
does.
Fixes #218
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJpXUy8JcVGpjDmK1MMHKb
|
This was referenced Sep 17, 2026
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.



Fixes #218
What #218 found, and what is left of it
The issue reported that the two readers of
dimensions.jsontestedphysicalConstraintsby different rules — the C# generator on the value (MinExclusive == "0"), the C++ projection on the presence of the object — so the first constraint declared that wasn'tminExclusive: "0"would have given one declared quantity two domains depending on which language it was generated into.The behavioural half of that has already landed. The
Semantics.Vocabularyextraction moved the decision intoQuantityVocabulary.BoundOf, and both projections now feed it the same value-based flag.Semantics.Cpp/QuantityVocabulary.cs:155, the line the issue quotes, no longer exists. So there is no live divergence to fix, and no generated output changes here.What was left is the part the issue called "better still", and its third acceptance bullet:
overload.PhysicalConstraints?.MinExclusive == "0", one per reader — which is exactly the "one metadata file read by two generators with no shared decision logic" the issue objects to, and how the two came to hold different rules in the first place;Wavelength,Period,HalfLife) are all{ "minExclusive": "0" }, where both rules agree. The divergence was invisible to the whole suite.The change
One implementation.
OverloadDeclaration.IsStrictFloor(string?)inSemantics.Vocabulary, which bothMetadataProjection(C++) andVocabularyProjection(C#) now ask rather than restate.Semantics.Vocabularyis already compiled into both, so this costs no new reference. Behaviour is identical — the two comments that carried the rule in prose now point at the function that holds it.The cases that separate the rules.
Semantics.Cpp.Test/StrictFloorTests.cs, driven by a metadata document written for the purpose rather than the real one, because the distinguishing constraint is one the real file does not declare yet — the point is to fail on the day it does:{ "minExclusive": "0" }assert(value.count() > 0{ }assert(value.count() >= 0{ "minExclusive": "1" }assert(value.count() >= 0assert(value.count() >= 0plus a table over
IsStrictFlooritself, which is now the single point both projections answer from.Verification
Temporarily restoring the pre-fix presence-based rule in
MetadataProjectionfails exactly the two new cases the old rule got wrong, and nothing else in the suite:With the rule in place:
Semantics.Cpp.Test— 43/43 passSemantics.Test— 1273 pass, 8 skipped (Windows-only)dotnet build Semantics.sln -warnaserror— succeeds, no new warningsgit statusclean of generated-source churn, as expected for a behaviour-preserving changenet9.0was compiled but not executed locally — the container has only the .NET 10 runtime. CI covers it.Not in scope
The issue's sibling, #216, asks for the dimensional-exponent check to be ported into the .NET generator. That is a separate diagnostic and is left alone here.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WJpXUy8JcVGpjDmK1MMHKb
Generated by Claude Code