diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-17 15:27:34 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-17 15:27:34 -0400 |
| commit | 4188d627c6869cb6b443ae3b6dece40486f4a039 (patch) | |
| tree | 018d309e84cd752c93a3b55770fcd979e0d35c54 /src/structs.c | |
| parent | 82466a2f9507ad6991c5a275d2be97691ef58db6 (diff) | |
Bugfix: added support for Tomo identifiers that are C keywords
Diffstat (limited to 'src/structs.c')
| -rw-r--r-- | src/structs.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/structs.c b/src/structs.c index 3e51f81b..873300c5 100644 --- a/src/structs.c +++ b/src/structs.c @@ -4,11 +4,12 @@ #include <stdio.h> #include "ast.h" -#include "stdlib/text.h" #include "compile.h" #include "environment.h" -#include "typecheck.h" +#include "naming.h" +#include "stdlib/text.h" #include "stdlib/util.h" +#include "typecheck.h" Text_t compile_struct_typeinfo(env_t *env, type_t *t, const char *name, arg_ast_t *fields, bool is_secret, bool is_opaque) { @@ -60,7 +61,7 @@ Text_t compile_struct_header(env_t *env, ast_t *ast) else if (field->value) code_err(field->value, "This is an opaque type, so it can't be used as a struct field type"); } - fields = Texts(fields, compile_declaration(field_t, Text$from_str(field->name)), + fields = Texts(fields, compile_declaration(field_t, valid_c_name(field->name)), field_t->tag == BoolType ? Text(":1") : EMPTY_TEXT, ";\n"); } Text_t struct_code = def->external ? EMPTY_TEXT : Texts(type_code, " {\n", fields, "};\n"); |
