Skip to content

Commit

Permalink
Move helper functions to the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-oq committed May 2, 2023
1 parent e77a0fb commit 827ae9f
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@ export abstract class DefaultUnaryOperatorTypeComputer
): PropertyValuetype;
}

export function convertsImplicitlyTo(
from: PropertyValuetype,
to: PropertyValuetype,
) {
return (
from === to ||
(from === PropertyValuetype.INTEGER && to === PropertyValuetype.DECIMAL)
);
}

function generateUnexpectedTypeMessage(
expectedTypes: PropertyValuetype | PropertyValuetype[],
actualType: PropertyValuetype,
) {
return `The operand needs to be of type ${
Array.isArray(expectedTypes) ? expectedTypes.join(' or ') : expectedTypes
} but is of type ${actualType}`;
}

export interface BinaryOperatorTypeComputer {
/**
* Computes the type of a binary operator by the type of its operands.
Expand Down Expand Up @@ -144,3 +125,22 @@ export abstract class DefaultBinaryOperatorTypeComputer
rightOperandType: PropertyValuetype,
): PropertyValuetype;
}

export function convertsImplicitlyTo(
from: PropertyValuetype,
to: PropertyValuetype,
) {
return (
from === to ||
(from === PropertyValuetype.INTEGER && to === PropertyValuetype.DECIMAL)
);
}

function generateUnexpectedTypeMessage(
expectedTypes: PropertyValuetype | PropertyValuetype[],
actualType: PropertyValuetype,
) {
return `The operand needs to be of type ${
Array.isArray(expectedTypes) ? expectedTypes.join(' or ') : expectedTypes
} but is of type ${actualType}`;
}

0 comments on commit 827ae9f

Please sign in to comment.