Skip to content

Commit

Permalink
fix struct field name using c keyword 'typeof'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Nov 7, 2024
1 parent 107167a commit 83dd010
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const c_reserved = ['asm', 'array', 'auto', 'bool', 'break', 'calloc', 'case', '
'exit', 'export', 'extern', 'false', 'float', 'for', 'free', 'goto', 'if', 'inline', 'int',
'link', 'long', 'malloc', 'namespace', 'new', 'nil', 'panic', 'register', 'restrict', 'return',
'short', 'signed', 'sizeof', 'static', 'string', 'struct', 'switch', 'typedef', 'typename',
'union', 'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small', 'stdout',
'stdin', 'stderr', 'far', 'near', 'huge', 'requires']
'typeof', 'union', 'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small',
'stdout', 'stdin', 'stderr', 'far', 'near', 'huge', 'requires']
const c_reserved_chk = token.new_keywords_matcher_from_array_trie(c_reserved)
// same order as in token.Kind
const cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le']
Expand Down
9 changes: 9 additions & 0 deletions vlib/v/tests/structs/struct_field_name_using_c_keyword_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct Keywords {
typeof u8
}

fn test_struct_field_name_using_c_reserved() {
key := Keywords{}
println(key)
assert true
}

0 comments on commit 83dd010

Please sign in to comment.