small improvements

This commit is contained in:
nora 2023-07-29 22:12:05 +02:00
parent 3270e6b501
commit f0227af982
4 changed files with 36 additions and 32 deletions

View file

@ -641,23 +641,6 @@ export function checkBody(
}
function checkBinary(expr: Expr & ExprBinary): Expr {
const checkPrecedence = (inner: Expr, side: string) => {
if (inner.kind === "binary") {
const ourClass = binaryExprPrecedenceClass(expr.binaryKind);
const innerClass = binaryExprPrecedenceClass(inner.binaryKind);
if (ourClass !== innerClass) {
throw new CompilerError(
`mixing operators without parentheses is not allowed. ${side} is ${inner.binaryKind}, which is different from ${expr.binaryKind}`,
expr.span
);
}
}
};
checkPrecedence(expr.lhs, "left");
checkPrecedence(expr.rhs, "right");
let lhsTy = expr.lhs.ty!;
let rhsTy = expr.rhs.ty!;