public CodeType Type()
 {
     if (Consequent.Type() == Alternative.Type())
     {
         return(Consequent.Type());
     }
     return(null);
 }
 public CodeType Type()
 {
     // Consequent or Alternative can equal null on GetExpression failure.
     if (Consequent != null && Alternative != null && Consequent.Type() == Alternative.Type())
     {
         return(Consequent.Type());
     }
     return(null);
 }
        public TernaryConditionalAction(ParseInfo parseInfo, Scope scope, TernaryExpression ternaryContext)
        {
            this.parseInfo = parseInfo;

            Condition   = parseInfo.GetExpression(scope, ternaryContext.Condition);
            Consequent  = parseInfo.GetExpression(scope, ternaryContext.Consequent);
            Alternative = parseInfo.GetExpression(scope, ternaryContext.Alternative);

            if (Consequent.Type() != null && Consequent.Type().IsConstant())
            {
                parseInfo.Script.Diagnostics.Error($"Cannot use constant types in a ternary expression.", ternaryContext.Consequent.Range);
            }
            if (Alternative.Type() != null && Alternative.Type().IsConstant())
            {
                parseInfo.Script.Diagnostics.Error($"Cannot use constant types in a ternary expression.", ternaryContext.Alternative.Range);
            }
        }