Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mixing implicit and explicit call parameters

A call mixes positional (implicit) arguments with named (explicit) arguments. The compiler accepts this, but the resolution is order-sensitive: named args first claim their slots, and any remaining positional args fill the leftover slots left-to-right. This is easy to misread and easy to break by reordering.

Example:

FUNCTION myfunc : INT
VAR_INPUT
    a : INT;
    b : INT;
    c : INT;
END_VAR
END_FUNCTION

PROGRAM main
VAR x : INT; END_VAR
    // `b := 20` claims slot 1; positional `1` fills slot 0 (a), `3` fills slot 2 (c).
    x := myfunc(b := 20, 1, 3);
END_PROGRAM

Prefer one style per call - fully positional or fully named - so a reader can see the mapping at a glance. If a mix is genuinely the clearest option (e.g. to override one default in the middle of a long parameter list), name every argument whose position isn’t obvious.

To silence this warning, rewrite the call with a single convention:

    x := myfunc(1, 20, 3);                    // all positional
    x := myfunc(a := 1, b := 20, c := 3);     // all named

See also E131 — positional arg collides with later named arg — which catches the more dangerous case where a positional argument’s natural slot is also named, and the resolver silently shifts it to a different parameter.