contrib/schemagen/weaseljson_schemagen.py builds C++ enum class constants in _enums (lines 506-512) by running each JSON enum value through sanitize (line 75). It does not check whether two distinct JSON values sanitize to the same C++ identifier.
Both values sanitize to foo_bar, so the generated header contains:
enumclassRole:int{foo_bar,foo_bar};
This is invalid C++ and fails to compile with:
error: redeclaration of ‘foo_bar’
The schema itself is valid, so the generator should either deduplicate the sanitized identifiers (while still matching the original JSON values in matchKey) or emit a clear generation-time error when enum values collide.
`contrib/schemagen/weaseljson_schemagen.py` builds C++ `enum class` constants in `_enums` (lines 506-512) by running each JSON enum value through `sanitize` (line 75). It does not check whether two distinct JSON values sanitize to the same C++ identifier.
Example schema:
```json
{
"type": "object",
"properties": {
"role": {
"enum": ["foo-bar", "foo_bar"]
}
}
}
```
Both values sanitize to `foo_bar`, so the generated header contains:
```cpp
enum class Role : int { foo_bar, foo_bar };
```
This is invalid C++ and fails to compile with:
```
error: redeclaration of ‘foo_bar’
```
The schema itself is valid, so the generator should either deduplicate the sanitized identifiers (while still matching the original JSON values in `matchKey`) or emit a clear generation-time error when enum values collide.
weaselbot
was assigned by andrew2026-06-18 14:05:35 +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.
contrib/schemagen/weaseljson_schemagen.pybuilds C++enum classconstants in_enums(lines 506-512) by running each JSON enum value throughsanitize(line 75). It does not check whether two distinct JSON values sanitize to the same C++ identifier.Example schema:
Both values sanitize to
foo_bar, so the generated header contains:This is invalid C++ and fails to compile with:
The schema itself is valid, so the generator should either deduplicate the sanitized identifiers (while still matching the original JSON values in
matchKey) or emit a clear generation-time error when enum values collide.