public override ITypeCheckType TypeCheck(ITypeEnvironment env) { ITypeCheckType a = Expr1.TypeCheck(env); ITypeCheckType b = Expr2.TypeCheck(env); if (!a.CompatibleWith(ExpressionUpperBound) || !a.CompatibleWith(b)) { env.ReportError(String.Format("Subtraction not possible. Incompatible types: '{0}', '{1}'. Only numeric types are supported.", a, b), SourceStartPosition, SourceEndPosition); return(ExpressionUpperBound); } return(a.GetLeastUpperBound(b)); }
public ITypeCheckType TypeCheck(ITypeEnvironment env) { ITypeCheckType a = Expr1.TypeCheck(env); ITypeCheckType b = Expr2.TypeCheck(env); ITypeCheckType c = Expr3.TypeCheck(env); if (!a.CompatibleWith(ExpressionUpperBound)) { env.ReportError(String.Format("Inline 'if/else' evaluation failed. Incompatible type: '{0}'. Only the bool type is supported.", a), SourceStartPosition, SourceEndPosition); } if (!b.CompatibleWith(c)) { env.ReportError(String.Format("Inline 'if/else' return value conflict. Incompatible types: '{0}', '{1}'. Only similar types can be used in the true/false bodies.", b, c), SourceStartPosition, SourceEndPosition); } return(b.GetLeastUpperBound(c)); }