From f493076882c6b0ee33fb1ca67c7562f96c2242ca Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 4 Aug 2026 00:55:27 -0700 Subject: [PATCH] Add regression test for nested class method calls Check that an unqualified method call from a named block uses the implicit `this` signal from the containing class method. The compiler currently looks for the signal in the named-block scope and crashes. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_class_nested_method_call.v | 30 +++++++++++++++++++ ivtest/regress-vvp.list | 1 + .../sv_class_nested_method_call.json | 9 ++++++ 3 files changed, 40 insertions(+) create mode 100644 ivtest/ivltests/sv_class_nested_method_call.v create mode 100644 ivtest/vvp_tests/sv_class_nested_method_call.json diff --git a/ivtest/ivltests/sv_class_nested_method_call.v b/ivtest/ivltests/sv_class_nested_method_call.v new file mode 100644 index 000000000..c9b2cfe3c --- /dev/null +++ b/ivtest/ivltests/sv_class_nested_method_call.v @@ -0,0 +1,30 @@ +// Check that an unqualified class method call works from a named block in +// another method. + +module test; + + class C; + function int get_value(); + return 1; + endfunction + + function int call_method(); + begin : nested + return get_value(); + end + endfunction + endclass + + C object; + + initial begin + object = new; + + if (object.call_method() != 1) begin + $display("FAILED"); + end else begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 21d0b57b4..5453cb1ca 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -285,6 +285,7 @@ sv_chained_constructor2 vvp_tests/sv_chained_constructor2.json sv_chained_constructor3 vvp_tests/sv_chained_constructor3.json sv_chained_constructor4 vvp_tests/sv_chained_constructor4.json sv_chained_constructor5 vvp_tests/sv_chained_constructor5.json +sv_class_nested_method_call vvp_tests/sv_class_nested_method_call.json sv_class_prop_assign_op1 vvp_tests/sv_class_prop_assign_op1.json sv_class_prop_assign_op2 vvp_tests/sv_class_prop_assign_op2.json sv_class_prop_class_name vvp_tests/sv_class_prop_class_name.json diff --git a/ivtest/vvp_tests/sv_class_nested_method_call.json b/ivtest/vvp_tests/sv_class_nested_method_call.json new file mode 100644 index 000000000..c83ca1546 --- /dev/null +++ b/ivtest/vvp_tests/sv_class_nested_method_call.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "sv_class_nested_method_call.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Classes are not supported", + "type" : "CE" + } +}