Informix Error -4076
-4076 Class of CAST object must be a base of class specified as right
argument.You cannot cast an object to any class; you can only cast it as being of a class that is derived from its stated class. In the CAST expression in this statement, the stated class of the object reference on the left is not a base class of the class that is named as the right argument. Review the expression to make sure that you have specified the object that you intended (possibly you need to use parentheses around the object reference) and the target class.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4076 fires when a CAST expression's target class isn't derived from the object's stated
class — per the official guidance, you can only cast an object to a class that's derived from
its stated class, not to any arbitrary class.
- A
CASTtarget class that isn't derived from the object's stated (declared) class, per the official guidance — the direct, only cause.
Solutions / Resolution
- Review the expression to confirm the object intended (parentheses around the object reference may be needed), per the official guidance.
- Confirm the target class is genuinely derived from the object's stated class, per the official guidance.
Examples
Casting to an unrelated class
DEFINE o BaseClass
LET x = CAST(o AS UnrelatedClass)
-- -4076: UnrelatedClass is not derived from BaseClass
Corrected
LET x = CAST(o AS DerivedClass)
-- DerivedClass IS derived from BaseClass
Diagnostic Checks
- Check the class hierarchy to confirm the
CASTtarget class is genuinely derived from the object's stated class.
Related Errors / Related Topics
- -4020 — "Function "member" is not a member of class "class"." A related member-access
error that mentions
CASTas the way to call a member of an object's actual class, which this error's own condition can prevent from succeeding.
A CAST expression's target class isn't derived from the object's stated class — check the
class hierarchy.