From 9edaf7b6ace3fbf31e9aaa20e6c33ce09ec2535a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 22 Aug 2026 18:17:06 -0700 Subject: [PATCH] Add regressions for deferred type elaboration failures A function declaration creates a nested scope whose name is visible throughout its containing scope. Check that a later function named `T` hides an outer typedef while elaborating an earlier signal, a class property, and a typed constructor. These consumers take different paths after type lookup. Verify that each reports the failed lookup without asserting or dereferencing the missing type. Signed-off-by: Lars-Peter Clausen --- ...s_property_shadow_fail-iverilog-stderr.gold | 2 ++ ...tion_scope_shadow_fail-iverilog-stderr.gold | 2 ++ ...onstructor_shadow_fail-iverilog-stderr.gold | 4 ++++ ...ype_identifier_class_property_shadow_fail.v | 14 ++++++++++++++ ...ype_identifier_function_scope_shadow_fail.v | 13 +++++++++++++ ..._identifier_typed_constructor_shadow_fail.v | 18 ++++++++++++++++++ ivtest/regress-vvp.list | 3 +++ ..._identifier_class_property_shadow_fail.json | 6 ++++++ ..._identifier_function_scope_shadow_fail.json | 6 ++++++ ...entifier_typed_constructor_shadow_fail.json | 6 ++++++ 10 files changed, 74 insertions(+) create mode 100644 ivtest/gold/sv_type_identifier_class_property_shadow_fail-iverilog-stderr.gold create mode 100644 ivtest/gold/sv_type_identifier_function_scope_shadow_fail-iverilog-stderr.gold create mode 100644 ivtest/gold/sv_type_identifier_typed_constructor_shadow_fail-iverilog-stderr.gold create mode 100644 ivtest/ivltests/sv_type_identifier_class_property_shadow_fail.v create mode 100644 ivtest/ivltests/sv_type_identifier_function_scope_shadow_fail.v create mode 100644 ivtest/ivltests/sv_type_identifier_typed_constructor_shadow_fail.v create mode 100644 ivtest/vvp_tests/sv_type_identifier_class_property_shadow_fail.json create mode 100644 ivtest/vvp_tests/sv_type_identifier_function_scope_shadow_fail.json create mode 100644 ivtest/vvp_tests/sv_type_identifier_typed_constructor_shadow_fail.json diff --git a/ivtest/gold/sv_type_identifier_class_property_shadow_fail-iverilog-stderr.gold b/ivtest/gold/sv_type_identifier_class_property_shadow_fail-iverilog-stderr.gold new file mode 100644 index 000000000..6c7d6c04f --- /dev/null +++ b/ivtest/gold/sv_type_identifier_class_property_shadow_fail-iverilog-stderr.gold @@ -0,0 +1,2 @@ +ivltests/sv_type_identifier_class_property_shadow_fail.v:6: error: `T` is not a type. +1 error(s) during elaboration. diff --git a/ivtest/gold/sv_type_identifier_function_scope_shadow_fail-iverilog-stderr.gold b/ivtest/gold/sv_type_identifier_function_scope_shadow_fail-iverilog-stderr.gold new file mode 100644 index 000000000..a9e3d456a --- /dev/null +++ b/ivtest/gold/sv_type_identifier_function_scope_shadow_fail-iverilog-stderr.gold @@ -0,0 +1,2 @@ +ivltests/sv_type_identifier_function_scope_shadow_fail.v:7: error: `T` is not a type. +1 error(s) during elaboration. diff --git a/ivtest/gold/sv_type_identifier_typed_constructor_shadow_fail-iverilog-stderr.gold b/ivtest/gold/sv_type_identifier_typed_constructor_shadow_fail-iverilog-stderr.gold new file mode 100644 index 000000000..e8c25ba3f --- /dev/null +++ b/ivtest/gold/sv_type_identifier_typed_constructor_shadow_fail-iverilog-stderr.gold @@ -0,0 +1,4 @@ +ivltests/sv_type_identifier_typed_constructor_shadow_fail.v:12: error: `T` is not a type. +ivltests/sv_type_identifier_typed_constructor_shadow_fail.v:12: error: Incompatible type in typed constructor call. +ivltests/sv_type_identifier_typed_constructor_shadow_fail.v:12: : Constructor type `netvector_t:logic unsigned` is not a class type. +Elaboration failed diff --git a/ivtest/ivltests/sv_type_identifier_class_property_shadow_fail.v b/ivtest/ivltests/sv_type_identifier_class_property_shadow_fail.v new file mode 100644 index 000000000..e08981b12 --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_class_property_shadow_fail.v @@ -0,0 +1,14 @@ +// Check that a function name can invalidate an earlier property type. + +typedef int T; + +class C; + T value; + + function T; + T = 0; + endfunction +endclass + +module test; +endmodule diff --git a/ivtest/ivltests/sv_type_identifier_function_scope_shadow_fail.v b/ivtest/ivltests/sv_type_identifier_function_scope_shadow_fail.v new file mode 100644 index 000000000..d520c755a --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_function_scope_shadow_fail.v @@ -0,0 +1,13 @@ +// Check that a function scope hides an outer typedef. + +typedef reg [7:0] T; + +module test; + + T x; + + function T; + T = 0; + endfunction + +endmodule diff --git a/ivtest/ivltests/sv_type_identifier_typed_constructor_shadow_fail.v b/ivtest/ivltests/sv_type_identifier_typed_constructor_shadow_fail.v new file mode 100644 index 000000000..164f27f8d --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_typed_constructor_shadow_fail.v @@ -0,0 +1,18 @@ +// Check that a function name can invalidate an earlier constructor type. + +class C; +endclass + +typedef C T; + +module test; + + C value; + + initial value = T::new; + + function T; + T = 0; + endfunction + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index f937878d9..dd9a8428f 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -509,6 +509,7 @@ sv_type_identifier_attribute_name vvp_tests/sv_type_identifier_attribute_name.js sv_type_identifier_attribute_target vvp_tests/sv_type_identifier_attribute_target.json sv_type_identifier_block_label_name vvp_tests/sv_type_identifier_block_label_name.json sv_type_identifier_block_prefix_label_name vvp_tests/sv_type_identifier_block_prefix_label_name.json +sv_type_identifier_class_property_shadow_fail vvp_tests/sv_type_identifier_class_property_shadow_fail.json sv_type_identifier_config_name vvp_tests/sv_type_identifier_config_name.json sv_type_identifier_dim_indexed_fail vvp_tests/sv_type_identifier_dim_indexed_fail.json sv_type_identifier_dim_queue_fail vvp_tests/sv_type_identifier_dim_queue_fail.json @@ -527,6 +528,7 @@ sv_type_identifier_foreach_name vvp_tests/sv_type_identifier_foreach_name.json sv_type_identifier_fork_label_name vvp_tests/sv_type_identifier_fork_label_name.json sv_type_identifier_fork_prefix_label_name vvp_tests/sv_type_identifier_fork_prefix_label_name.json sv_type_identifier_function_name vvp_tests/sv_type_identifier_function_name.json +sv_type_identifier_function_scope_shadow_fail vvp_tests/sv_type_identifier_function_scope_shadow_fail.json sv_type_identifier_generate_label_name vvp_tests/sv_type_identifier_generate_label_name.json sv_type_identifier_genvar_name vvp_tests/sv_type_identifier_genvar_name.json sv_type_identifier_hier_empty_fail vvp_tests/sv_type_identifier_hier_empty_fail.json @@ -573,6 +575,7 @@ sv_type_identifier_type_dimension_param vvp_tests/sv_type_identifier_type_dimens sv_type_identifier_type_dimension_sysfunc vvp_tests/sv_type_identifier_type_dimension_sysfunc.json sv_type_identifier_type_lookup vvp_tests/sv_type_identifier_type_lookup.json sv_type_identifier_type_param_hier_fail vvp_tests/sv_type_identifier_type_param_hier_fail.json +sv_type_identifier_typed_constructor_shadow_fail vvp_tests/sv_type_identifier_typed_constructor_shadow_fail.json sv_type_identifier_typed_expression vvp_tests/sv_type_identifier_typed_expression.json sv_type_identifier_typed_expression_fail vvp_tests/sv_type_identifier_typed_expression_fail.json sv_type_identifier_udp_ansi_name vvp_tests/sv_type_identifier_udp_ansi_name.json diff --git a/ivtest/vvp_tests/sv_type_identifier_class_property_shadow_fail.json b/ivtest/vvp_tests/sv_type_identifier_class_property_shadow_fail.json new file mode 100644 index 000000000..91b982fb4 --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_class_property_shadow_fail.json @@ -0,0 +1,6 @@ +{ + "type" : "CE", + "source" : "sv_type_identifier_class_property_shadow_fail.v", + "gold" : "sv_type_identifier_class_property_shadow_fail", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_type_identifier_function_scope_shadow_fail.json b/ivtest/vvp_tests/sv_type_identifier_function_scope_shadow_fail.json new file mode 100644 index 000000000..0c7ca70d5 --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_function_scope_shadow_fail.json @@ -0,0 +1,6 @@ +{ + "type" : "CE", + "source" : "sv_type_identifier_function_scope_shadow_fail.v", + "gold" : "sv_type_identifier_function_scope_shadow_fail", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_type_identifier_typed_constructor_shadow_fail.json b/ivtest/vvp_tests/sv_type_identifier_typed_constructor_shadow_fail.json new file mode 100644 index 000000000..35bc81909 --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_typed_constructor_shadow_fail.json @@ -0,0 +1,6 @@ +{ + "type" : "CE", + "source" : "sv_type_identifier_typed_constructor_shadow_fail.v", + "gold" : "sv_type_identifier_typed_constructor_shadow_fail", + "iverilog-args" : [ "-g2005-sv" ] +}