From 20013e4b4b5a9a57f780218abd4096a68dd88810 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 30 Apr 2020 16:48:46 +0200 Subject: [PATCH] table: interfaces: unique gen_types --- vlib/v/table/table.v | 4 +++- vlib/v/tests/interface_test.v | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vlib/v/table/table.v b/vlib/v/table/table.v index aa52be1f78..5bf867deeb 100644 --- a/vlib/v/table/table.v +++ b/vlib/v/table/table.v @@ -490,7 +490,9 @@ pub fn (t &Table) check(got, expected Type) bool { mut info := exp_type_sym.info as Interface // println('gen_types before') // println(info.gen_types) - info.gen_types << got_type_sym.name + if got_type_sym.name !in info.gen_types { + info.gen_types << got_type_sym.name + } // println('adding gen_type $got_type_sym.name') // println(info.gen_types) return true diff --git a/vlib/v/tests/interface_test.v b/vlib/v/tests/interface_test.v index 087d211a79..e6f30015a2 100644 --- a/vlib/v/tests/interface_test.v +++ b/vlib/v/tests/interface_test.v @@ -46,6 +46,7 @@ fn test_perform_speak() { perform_speak(dog) cat := Cat{} perform_speak(cat) + perform_speak(Cat{}) perform_speakers([dog, cat]) /* f := Foo {