Skip to content

Commit c5f2ab4

Browse files
apullinclaude
andcommitted
Fix #716: Report error for incompatible task argument types
When an undimensioned (dynamic) array was passed to a task parameter expecting a simple vector, the compiler would crash with an assertion failure because the switch handling type casts didn't know how to handle IVL_VT_DARRAY type. Changed the assertion to emit a proper error message about type incompatibility and continue processing, allowing the compiler to report the error gracefully instead of crashing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8f832f9 commit c5f2ab4

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

elaborate.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4342,9 +4342,15 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope,
43424342
rv = cast_to_int4(rv, lv_width);
43434343
break;
43444344
default:
4345-
/* Don't yet know how to handle this. */
4346-
ivl_assert(*this, 0);
4347-
break;
4345+
/* Cannot cast between these types. */
4346+
cerr << get_fileline() << ": error: "
4347+
<< "Type of task port " << (idx+1)
4348+
<< " is not compatible with the argument type."
4349+
<< endl;
4350+
des->errors += 1;
4351+
delete rv;
4352+
delete lv;
4353+
continue;
43484354
}
43494355
}
43504356
rv = pad_to_width(rv, lv_width, *this);

ivtest/gold/br_gh716.gold

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
./ivltests/br_gh716.v:11: error: Type of task port 1 is not compatible with the argument type.
2+
1 error(s) during elaboration.

ivtest/ivltests/br_gh716.v

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Test for GitHub issue #716
2+
// Undimensioned array passed to task expecting single vector should error
3+
module test();
4+
logic [7:0] mybuf [];
5+
6+
task t1(output logic [7:0] buffer);
7+
buffer = 0;
8+
endtask
9+
10+
initial begin
11+
t1(mybuf);
12+
end
13+
endmodule

ivtest/regress-sv.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ br_gh661a normal,-g2009 ivltests
223223
br_gh661b normal,-g2009 ivltests
224224
br_gh672 normal,-g2009 ivltests
225225
br_gh699 CE,-g2009 ivltests
226+
br_gh716 CE,-g2012 ivltests gold=br_gh716.gold
226227
br_gh756 normal,-g2009 ivltests
227228
br_gh782a normal,-g2009 ivltests gold=br_gh782a.gold
228229
br_gh782b normal,-g2009 ivltests gold=br_gh782b.gold

0 commit comments

Comments
 (0)