P4013

Code

P4013

Message

POU declaration name is duplicated

This error occurs when a POU (Program Organization Unit) declaration name is duplicated within the same scope.

Example

The following code will generate error P4013:

FUNCTION_BLOCK MyFunction
    VAR
        x : INT;
    END_VAR
END_FUNCTION_BLOCK

FUNCTION_BLOCK MyFunction  (* Error: Duplicate POU name *)
    VAR
        y : INT;
    END_VAR
END_FUNCTION_BLOCK

PROGRAM main
    VAR
        dummy : INT;
    END_VAR
END_PROGRAM

The function block MyFunction is declared twice, which is not allowed.

To fix this error, ensure all POU names are unique within their scope:

FUNCTION_BLOCK MyFunction1
    VAR
        x : INT;
    END_VAR
END_FUNCTION_BLOCK

FUNCTION_BLOCK MyFunction2
    VAR
        y : INT;
    END_VAR
END_FUNCTION_BLOCK

PROGRAM main
    VAR
        dummy : INT;
    END_VAR
END_PROGRAM

The conflict is also raised across POU kinds. The following code collides a FUNCTION with a FUNCTION_BLOCK of the same name and still produces P4013:

FUNCTION Compute : INT
    Compute := 0;
END_FUNCTION

FUNCTION_BLOCK Compute  (* Error: name collides with the FUNCTION above *)
    VAR
        x : INT;
    END_VAR
END_FUNCTION_BLOCK

PROGRAM main
    VAR
        dummy : INT;
    END_VAR
END_PROGRAM

Rename one of the POUs (for example, ComputeResult and ComputeBlock) to resolve the conflict.

See Also

  • Program Organization Units — POU kinds and declaration syntax

  • FUNCTIONFUNCTION declarations

  • FUNCTION_BLOCKFUNCTION_BLOCK declarations

  • P4014 — symbol (variable) declaration name duplicated

  • P4015 — user-defined type collides with a standard-library type

  • P4016 — function declaration name duplicated

References

Think IronPLC is wrong about this?

If you believe this diagnostic is incorrect, open an issue on GitHub with a small sample that demonstrates the problem.