The generator emits fixed names (Root, Arr0/Arr1/..., Skip, RootScalar) without reserving them in unique_name. Valid schemas that define $defs entries whose camel-cased names happen to match those generated identifiers produce non-compilable headers.
Relevant generator code in contrib/schemagen/weaseljson_schemagen.py:
Lines 206-214 (unique_name): only avoids collisions among user-chosen object/enum names; it never reserves Root, Skip, RootScalar, or array-kind names.
Lines 564-570 (_root_alias): always emits using Root = ....
conflicting declaration ‘using weasel_schema::Root = class std::vector<weasel_schema::Root>’
note: previous declaration as ‘enum class weasel_schema::Root’
error: redeclaration of ‘Arr0’
error: duplicate case value
Impact: ordinary, valid JSON schemas (e.g., a $defs entry named "Root", "Skip", or "Arr0") fail at C++ compile time instead of producing a working parser.
The generator emits fixed names (`Root`, `Arr0`/`Arr1`/..., `Skip`, `RootScalar`) without reserving them in `unique_name`. Valid schemas that define `$defs` entries whose camel-cased names happen to match those generated identifiers produce non-compilable headers.
Relevant generator code in `contrib/schemagen/weaseljson_schemagen.py`:
- Lines 206-214 (`unique_name`): only avoids collisions among user-chosen object/enum names; it never reserves `Root`, `Skip`, `RootScalar`, or array-kind names.
- Lines 564-570 (`_root_alias`): always emits `using Root = ...`.
- Lines 573-583 (`_kind_enum`): concatenates object names and `ArrN`/`Skip`/`RootScalar` kind names, allowing duplicates.
Reproduction 1 — `Root` alias collision:
```json
{
"type": "array",
"items": { "$ref": "#/$defs/Root" },
"$defs": {
"Root": { "enum": ["a", "b"] }
}
}
```
Generated:
```cpp
enum class Root : int { a, b };
using Root = std::vector<Root>;
```
Compiler error:
```
conflicting declaration ‘using weasel_schema::Root = class std::vector<weasel_schema::Root>’
note: previous declaration as ‘enum class weasel_schema::Root’
```
Reproduction 2 — `Kind` enumerator collision:
```json
{
"type": "object",
"properties": {
"arr": { "type": "array", "items": { "type": "string" } },
"obj": { "$ref": "#/$defs/Arr0" }
},
"$defs": {
"Arr0": { "type": "object", "properties": {} }
}
}
```
Generated:
```cpp
enum class Kind : uint8_t { Root, Arr0, Arr0, Skip };
```
Compiler errors:
```
error: redeclaration of ‘Arr0’
error: duplicate case value
```
Impact: ordinary, valid JSON schemas (e.g., a `$defs` entry named "Root", "Skip", or "Arr0") fail at C++ compile time instead of producing a working parser.
weaselbot
was assigned by andrew2026-06-23 14:58:29 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The generator emits fixed names (
Root,Arr0/Arr1/...,Skip,RootScalar) without reserving them inunique_name. Valid schemas that define$defsentries whose camel-cased names happen to match those generated identifiers produce non-compilable headers.Relevant generator code in
contrib/schemagen/weaseljson_schemagen.py:unique_name): only avoids collisions among user-chosen object/enum names; it never reservesRoot,Skip,RootScalar, or array-kind names._root_alias): always emitsusing Root = ...._kind_enum): concatenates object names andArrN/Skip/RootScalarkind names, allowing duplicates.Reproduction 1 —
Rootalias collision:Generated:
Compiler error:
Reproduction 2 —
Kindenumerator collision:Generated:
Compiler errors:
Impact: ordinary, valid JSON schemas (e.g., a
$defsentry named "Root", "Skip", or "Arr0") fail at C++ compile time instead of producing a working parser.