Skip to content

Call arguments

A call with a missing argument is a mistake a simulator reports only when it compiles. (A formal is an argument as the function declares it.) The Wrong arguments in a call inspection (a check the IDE runs as you type and shows in the editor) finds it at once: it underlines the called name when a function, task or constructor call leaves out an argument that has no default value, gives more arguments than declared, or names an argument that does not exist. It is on by default, at level Error.

The steps use the sample project; open it and wait for indexing first.

  1. Open classes/shapes.sv, find sq.scale(2.0); in shapes_demo (⌘F / Ctrl+F) and delete 2.0, so that the line reads sq.scale();.
  2. scale is underlined in red. Hover over it to read the message: Missing argument: 'factor'. (The class square declares function void scale(real factor), and the new on the line above is correct: square has no constructor arguments.)
  3. Press ⌘Z (macOS) / Ctrl+Z (Windows/Linux) until 2.0 is back (or retype it): the underline disappears.

If nothing is underlined, see If it doesn’t work.

Arguments are matched by position, then by name (.b(2)). An argument with a default may be left out, by position (f(1), f(1, )) or by name. The called name is underlined and the message is shown on hover:

Call Declaration Reported
x = two(1); function int two(int a, int b) Missing argument: 'b'
x = two(.a(1)); the same Missing argument: 'b'
x = two(, 2); the same: an empty position gives no value Missing argument: 'a'
t; task t(int x): a call without parentheses gives no arguments Missing argument: 'x'
x = two(1, 2, 3); function int two(int a, int b) Too many arguments: 'two' takes 2, 3 given
wait_done(.timeout(5)); task wait_done(int timeout_ns = 10) No argument named 'timeout': 'wait_done' has 'timeout_ns'
a = new; the class’s new(string name, int parent) (new is the constructor) Missing arguments: 'name', 'parent'

The same applies to UVM-style code, where the constructor of the base class (super is the class you extend) is called with super.new; see UVM testbenches:

Call Declaration Reported
a.exec_task(); task exec_task(uvm_component comp, uvm_phase phase) Missing arguments: 'comp', 'phase'
super.new(name); function new(string name, uvm_component parent) of the base class Missing argument: 'parent'

The defaults are those of the declaration the call resolves to: for a method declared extern in its class, its prototype. A class without its own new has one without arguments; a new that a macro in the class declares (`uvm_object_new) counts. The check is from IEEE 1800-2017 §13.5.

The IDE reports a call only when it sees every formal. A call is not checked where:

  • the callee’s formal list holds a macro, an `include or an inactive `ifdef branch (code the IDE treats as switched off because its condition is not defined; for new: in a class without its own new);
  • a macro in the class cannot be expanded;
  • a prototype’s formal (an argument of a declaration without a body) has no name (import "DPI-C" function int f(input int););
  • new is of a class named through a type parameter (T h = new(…), or super.new(…) of a class that extends a type parameter).

It is also not checked when:

  • the IDE cannot find the function or task, or finds it with different arguments in several places;
  • the callee is a system task or function ($display) or a built-in method (q.size(), randomize()). A built-in array method on an array of class handles (q.delete()) is the array’s, not the class’s method of the same name;
  • the call has a macro among its arguments (f(`ARGS): the macro may stand for several arguments), or is inside a macro’s arguments (`INFO("x", f(1)): the macro decides what they become), or inside a macro’s definition.

A call through a parameterized class (cfg_db#(int)::get(…)) is checked like any other.

You see Likely cause What to do
Nothing is underlined The inspection is turned off, or the project is still indexing Check Settings (⌘, / Ctrl+Alt+S) | Editor | Inspections | SystemVerilog | Wrong arguments in a call; wait for the progress bar at the bottom right
A wrong call is not underlined It is one of the cases above that are not checked (a macro, a callee the IDE cannot find) See When a call is not checked and Known limitations
A correct call is underlined The IDE resolved the call to a different declaration Check which declaration Go to Declaration (⌘B / Ctrl+B) opens

See also Troubleshooting.