Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
V7012. The conditional expression...
menu mobile close menu
Additional information
toggle menu Contents

V7012. The conditional expression always returns the same value.

Apr 03 2026

The analyzer detected a potential error in the use of the ?: ternary operator. The same action is performed for both possible outcomes of the condition. Most likely, there is a typo in the code or it is redundant.

Look at this example:

let result = flag ? x : x;

The result variable is always assigned the value of the x variable. Most likely, a developer intended to use another variable:

let result = flag ? x : y;

Non-identical but equivalent expressions are also taken into account. For example, for this code snippet:

let result = flag ? x * y : y * x;

The analyzer issues a warning, as the multiplication is commutative and the result will be equivalent.