From 24ec3966dcc0246f92c8ade4638bbfa1f70fb07e Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 11 May 2026 02:04:10 +0300 Subject: [PATCH] parser: set TypeSymbol.language for C aliases, so redefining a C type alias (e.g. type C.WCHAR = u16) works --- vlib/v/parser/parser.v | 1 + vlib/v/tests/aliases/c_alias_redeclaration_test.c.v | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 vlib/v/tests/aliases/c_alias_redeclaration_test.c.v diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index c1a6c23bf..41bd55a8d 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3278,6 +3278,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl { cname: util.no_dots(prepend_mod_name) mod: p.mod parent_idx: pidx + language: language info: ast.Alias{ parent_type: parent_type language: parent_language diff --git a/vlib/v/tests/aliases/c_alias_redeclaration_test.c.v b/vlib/v/tests/aliases/c_alias_redeclaration_test.c.v new file mode 100644 index 000000000..9105ecf30 --- /dev/null +++ b/vlib/v/tests/aliases/c_alias_redeclaration_test.c.v @@ -0,0 +1,11 @@ +// Redeclaring an existing C type alias should be accepted. Before the +// parser was setting TypeSymbol.language=.c for C aliases, the table's +// "Allow C type aliases to override existing C types" override never fired +// and the second declaration failed with `cannot register alias`. + +type C.RedeclareU16Alias = u16 +type C.RedeclareU16Alias = u16 + +fn test_c_alias_redeclaration_compiles() { + assert true +} -- 2.39.5