From c0dcd1a9a51bd981de704cae9cb385480612e9b6 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 24 Dec 2021 17:11:20 +0800 Subject: [PATCH] ast: fix reference of alias char type (#12951) --- vlib/v/ast/table.v | 2 +- vlib/v/tests/alias_char_type_reference_test.v | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/alias_char_type_reference_test.v diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 7068dcaec2..42b241b994 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -671,7 +671,7 @@ pub fn (t &Table) unalias_num_type(typ Type) Type { sym := t.sym(typ) if sym.kind == .alias { pt := (sym.info as Alias).parent_type - if pt <= f64_type && pt >= void_type { + if pt <= char_type && pt >= void_type { return pt } } diff --git a/vlib/v/tests/alias_char_type_reference_test.v b/vlib/v/tests/alias_char_type_reference_test.v new file mode 100644 index 0000000000..cc4c80cf32 --- /dev/null +++ b/vlib/v/tests/alias_char_type_reference_test.v @@ -0,0 +1,12 @@ +module main + +type ALchar = char + +fn test_alias_char_type_reference() { + c1 := &char(0) + c2 := &ALchar(0) + println('${typeof(c1).name} $c1') + assert '$c1' == '0' + println('${typeof(c2).name} $c2') + assert '$c2' == '0' +}