Informix Error -4012
-4012 You can only specify a base clause for class constructors.
This function declaration is followed by a colon, class-name, and argument list (in short, a base clause). This syntax is used only when declaring the constructor function for a class (the function whose name is the same as the name of the class), in order to specify function arguments to the constructor of the base class.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4012 fires when a non-constructor function declaration is followed by a base clause (a colon, class name, and argument list) — per the official guidance, that syntax is reserved for a class's constructor function (the function whose name matches the class name), to pass arguments to the base class's constructor.
- A base clause attached to a function that isn't the class constructor, per the official guidance — the direct, only cause.
Solutions / Resolution
- Remove the base clause from the non-constructor function, or rename the function to match the class name if a constructor was intended, consistent with the official guidance's description of where base clauses are valid.
Examples
A base clause on a non-constructor function
CLASS Order : BaseRecord
FUNCTION save() : BaseRecord(x)
-- -4012: save() is not the constructor (Order)
END FUNCTION
END CLASS
Corrected
CLASS Order : BaseRecord
FUNCTION Order() : BaseRecord(x)
...
END FUNCTION
END CLASS
Diagnostic Checks
- Check every function declaration using a base clause, and confirm its name matches the enclosing class name (i.e. it's the constructor).
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4012 in this set yet.
A base clause was used on a function that isn't the class constructor — remove it or rename the function to be the constructor.