public IType Evaluate(Scope scope) { IType t = target; if (target is IUnevaluated utarget) { t = utarget.Evaluate(scope); } if (t is Union union) { return(union.Apply(x => new UnaryOperatorExpression(pre, x))); } if (t is IUnevaluated) { return(new BakedExpression(new UnaryOperatorExpression(pre, t), scope)); } if (t is Error) { return(t); } // Operate if (t is IOperable oper) { if (oper.UnaryOperators != null && oper.UnaryOperators.TryGetValue(pre, out var action)) { IType ret = action.Invoke(); if (ret == null) { return(new Error("WrongType", $"The {pre.ToDisplayString()} operator cannot be applied to type {t.TypeName}")); } return(ret); } } return(new Error("WrongType", $"The {pre.ToDisplayString()} operator cannot be applied to type {t.TypeName}")); }