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 <[email protected]>
This commit is contained in:
Lars-Peter Clausen
2026-09-01 16:46:36 -07:00
parent 17db009f45
commit 9edaf7b6ac
10 changed files with 74 additions and 0 deletions
@@ -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.
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
+3
View File
@@ -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
@@ -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" ]
}
@@ -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" ]
}
@@ -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" ]
}