Informix Error -4151
-4151 Constructor cannot be called directly.
A constructor cannot be called directly using the CALL statement or as the function in a function call expression. The constructor should be invoked indirectly using the NEW operator.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4151 fires when a class constructor is invoked via CALL or as a function-call
expression — per the official guidance, constructors must be invoked indirectly through the
NEW operator.
- A constructor called directly via
CALLor as a function-call expression, per the official guidance — the direct, only cause.
Solutions / Resolution
- Invoke the constructor indirectly using the
NEWoperator, per the official guidance.
Examples
Calling a constructor directly
CALL Order()
-- -4151: constructors cannot be called directly
Corrected
DEFINE o Order
LET o = NEW Order()
Diagnostic Checks
- Check for any direct
CALLto a class constructor, and replace it withNEW.
Related Errors / Related Topics
- -4012 — "You can only specify a base clause for class constructors." A related constructor-declaration rule, about base clauses rather than direct invocation.
A constructor is called directly — use the NEW operator instead.