Expression recursively calls containing Operator '<operatorsymbol>'

An expression within an operator procedure uses the operator being defined. This results in the operator procedure calling itself because of the data types being used.

The operator procedure you are defining calls itself if it uses the same operator with any of the following:

  • The same operands for which you are defining the operator;

  • Operands of the same data types for which you are defining the operator; or

  • Operands of data types that widen to the data types for which you are defining the operator.

A recursive call is when a procedure calls itself. Recursive calls can result in an infinite loop, in which control passes through the same set of statements repeatedly until your application is terminated externally. If your code does not include one or more tests that can be used to terminate recursion, you risk an infinite loop.

By default, this message is a warning. For information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic.

Error ID: BC42004

To correct this error

  • If your logic requires the operator procedure to call itself, then be sure you test for at least one condition that is certain to occur at some point, and use this test to terminate the recursive calls.

  • If your logic does not require the operator procedure to call itself, then remove any recursive calls or replace them with statements that do not call their own procedure.

See Also

Tasks

How to: Define an Operator

How to: Define a Conversion Operator

Concepts

Operator Procedures

Reference

Operator Statement