From d246979d2620c05e959a2cc8587d6eb98367cdc3 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 21 Jun 2026 14:23:50 -0700 Subject: [PATCH] Add regression test for string substr() arity error Check that a string substr() call with too few arguments is rejected with a normal compile error. Signed-off-by: Lars-Peter Clausen --- .../sv_string_method_substr_too_few_arg_fail.v | 10 ++++++++++ ivtest/regress-vvp.list | 1 + .../sv_string_method_substr_too_few_arg_fail.json | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 ivtest/ivltests/sv_string_method_substr_too_few_arg_fail.v create mode 100644 ivtest/vvp_tests/sv_string_method_substr_too_few_arg_fail.json diff --git a/ivtest/ivltests/sv_string_method_substr_too_few_arg_fail.v b/ivtest/ivltests/sv_string_method_substr_too_few_arg_fail.v new file mode 100644 index 000000000..d0a45e78e --- /dev/null +++ b/ivtest/ivltests/sv_string_method_substr_too_few_arg_fail.v @@ -0,0 +1,10 @@ +// Check that string substr() rejects too few arguments. + +module test; + string s; + string t; + + initial begin + t = s.substr(0); + end +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 9655c20df..8b9eacb56 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -374,6 +374,7 @@ sv_queue_method_push_back_too_few_arg_fail vvp_tests/sv_queue_method_push_back_t sv_queue_method_push_back_too_many_arg_fail vvp_tests/sv_queue_method_push_back_too_many_arg_fail.json sv_queue_method_push_front_too_few_arg_fail vvp_tests/sv_queue_method_push_front_too_few_arg_fail.json sv_queue_method_push_front_too_many_arg_fail vvp_tests/sv_queue_method_push_front_too_many_arg_fail.json +sv_string_method_substr_too_few_arg_fail vvp_tests/sv_string_method_substr_too_few_arg_fail.json sv_soft_packed_union vvp_tests/sv_soft_packed_union.json sv_soft_packed_union_fail1 vvp_tests/sv_soft_packed_union_fail1.json sv_super_member_fail vvp_tests/sv_super_member_fail.json diff --git a/ivtest/vvp_tests/sv_string_method_substr_too_few_arg_fail.json b/ivtest/vvp_tests/sv_string_method_substr_too_few_arg_fail.json new file mode 100644 index 000000000..20453dfe5 --- /dev/null +++ b/ivtest/vvp_tests/sv_string_method_substr_too_few_arg_fail.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_string_method_substr_too_few_arg_fail.v", + "iverilog-args" : [ "-g2005-sv" ] +}