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 whose result is predetermined (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. The comparison coalescing operators (<?, >?,
<=?, >=?, ctx.coalescing_equality in the grammar) are checked for a
literal on BOTH sides.
The Elvis ?: is checked for a literal on the LEFT (Steve, D5, 2026-10-07): a literal
is always set, so 7 ?: fallback is always 7 and the right is never evaluated.
?? is deliberately not checked here (decision D2 is pending).
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionConstantCoalescingOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
emitTypeNotResolvedError, getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
ConstantCoalescingOrError
ConstantCoalescingOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.ExpressionContext>
-