Class ConstantCoalescingOrError
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.ConstantCoalescingOrError
- All Implemented Interfaces:
Consumer<EK9Parser.ExpressionContext>
final class ConstantCoalescingOrError
extends TypedSymbolAccess
implements Consumer<EK9Parser.ExpressionContext>
Detects coalescing expressions where both operands are literals (E08094).
Expressions like 5 <? 3 (always 3), "alpha" >? "beta" (always "beta"),
or 1.0 <=? 2.0 (always 1.0) have predetermined results and indicate logic errors,
dead code, or copy-paste mistakes.
Exemptions: coalescing expressions inside require, assert, and
constrain statements are not flagged, as these are test assertions where literal
expressions serve a documentation purpose.
Only the coalescing comparison operators (<?, >?, <=?,
>=?) are checked. These use ctx.coalescing_equality in the grammar,
not ctx.op.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionConstantCoalescingOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
ConstantCoalescingOrError
ConstantCoalescingOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.ExpressionContext>
-