From abd2b64700ecbb117a34ab51a777a84746addb1f Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 3 Feb 2024 15:25:54 -0300 Subject: [PATCH] tests: add test for cast as selector fix (see also #20717) (#20722) --- vlib/v/tests/as_cast_selector_test.v | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 vlib/v/tests/as_cast_selector_test.v diff --git a/vlib/v/tests/as_cast_selector_test.v b/vlib/v/tests/as_cast_selector_test.v new file mode 100644 index 0000000000..ed25d9b76a --- /dev/null +++ b/vlib/v/tests/as_cast_selector_test.v @@ -0,0 +1,18 @@ +struct Foo { +mut: + x int +} + +struct Bar { +mut: + y int +} + +type Foobar = Bar | Foo + +fn test_main() { + mut bar := Foobar(Bar{ + y: 123 + }) + assert bar as Bar.y == 123 +}