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

Positional argument collides with later named argument

In a mixed implicit/explicit call, a positional argument would naturally fill the same parameter that a later named argument also targets. The positional would spill into the next free slot - a silent reinterpretation that is almost never what the caller intended. This is an error because no legitimate code should depend on that disambiguation.

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

PROGRAM main
VAR x : INT; END_VAR
    // `1` sits in position 0 (param `a`), but `a := 10` also targets `a`.
    x := myfunc(1, a := 10);
END_PROGRAM

Rewrite the call so the intent is unambiguous - either name both arguments or drop the duplicate name.