The _CPP_KEYWORDS set in contrib/schemagen/weaseljson_schemagen.py (line 124) does not include several keywords added in C++20. When a JSON schema uses one of these words as a property name, the generated struct contains a C++ keyword as a member name and fails to compile.
Expected behavior: the generator should treat C++20 keywords the same way it treats older C++ keywords and Python keywords, appending a suffix (e.g. concept_) so the generated code compiles.
Impact: schemas that use ordinary English words such as "concept", "requires", or "import" as JSON keys cannot be turned into compilable C++ structs.
The `_CPP_KEYWORDS` set in `contrib/schemagen/weaseljson_schemagen.py` (line 124) does not include several keywords added in C++20. When a JSON schema uses one of these words as a property name, the generated struct contains a C++ keyword as a member name and fails to compile.
**Missing keywords include:** `concept`, `consteval`, `constinit`, `co_await`, `co_return`, `co_yield`, `requires`, `module`, `import`.
**Reproduction schema:**
```json
{
"type": "object",
"properties": {
"concept": { "type": "string" }
}
}
```
**Actual generated code (fails to compile):**
```cpp
struct Root {
std::optional<std::string> concept; // "concept"
};
```
Compiler error (GCC 16 / C++20):
```
concept.h:20:30: error: C++20 concept definition syntax is 'concept <name> = <expr>'
20 | std::optional<std::string> concept; // "concept"
| ^~~~~~~
```
**Expected behavior:** the generator should treat C++20 keywords the same way it treats older C++ keywords and Python keywords, appending a suffix (e.g. `concept_`) so the generated code compiles.
**Impact:** schemas that use ordinary English words such as "concept", "requires", or "import" as JSON keys cannot be turned into compilable C++ structs.
weaselbot
was assigned by andrew2026-06-21 15:01:45 +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
_CPP_KEYWORDSset incontrib/schemagen/weaseljson_schemagen.py(line 124) does not include several keywords added in C++20. When a JSON schema uses one of these words as a property name, the generated struct contains a C++ keyword as a member name and fails to compile.Missing keywords include:
concept,consteval,constinit,co_await,co_return,co_yield,requires,module,import.Reproduction schema:
Actual generated code (fails to compile):
Compiler error (GCC 16 / C++20):
Expected behavior: the generator should treat C++20 keywords the same way it treats older C++ keywords and Python keywords, appending a suffix (e.g.
concept_) so the generated code compiles.Impact: schemas that use ordinary English words such as "concept", "requires", or "import" as JSON keys cannot be turned into compilable C++ structs.