summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-11-29 10:26:30 +0000
committerMichael Williamson <mike@zwobble.org>2026-11-29 10:26:30 +0000
commit978bf81a82c61e9f2a9aa88d7e2b5882d1a86c45 (patch)
tree52dfeae6b99a31eb5785d823d48388de1eafa436
parent8d3f483be2127b04e7e90e06d207701b4b4f5c65 (diff)
Type check binary operations
-rw-r--r--hobgoblin/src/ast/typed.hob13
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNode.java64
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperator.java13
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedExpressionNode.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java35
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/errors/UnsupportedBinaryOperationError.java36
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNodeMatcher.java65
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerBinaryOperationTests.java65
8 files changed, 290 insertions, 3 deletions
diff --git a/hobgoblin/src/ast/typed.hob b/hobgoblin/src/ast/typed.hob
index dc016e5..dba76ea 100644
--- a/hobgoblin/src/ast/typed.hob
+++ b/hobgoblin/src/ast/typed.hob
@@ -108,6 +108,7 @@ struct TypedTableDefinitionNode {
// == Expressions ==
sum TypedExpressionNode {
+ variant TypedBinaryOperationNode;
variant TypedMemberAccessNode;
variant TypedNumberLiteralNode;
variant TypedReferenceNode;
@@ -115,6 +116,18 @@ sum TypedExpressionNode {
field type: Type;
}
+struct TypedBinaryOperationNode {
+ field operator: TypedBinaryOperator;
+ field left: TypedExpressionNode;
+ field right: TypedExpressionNode;
+ field type: Type;
+ field source: Source;
+}
+
+enum TypedBinaryOperator {
+ variant equals;
+}
+
struct TypedMemberAccessNode {
field receiver: TypedExpressionNode;
field memberName: String;
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNode.java
new file mode 100644
index 0000000..5575d17
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNode.java
@@ -0,0 +1,64 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.typed;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode imports
+
+public record TypedBinaryOperationNode(
+ org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator operator,
+ org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode left,
+ org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode right,
+ org.zwobble.hobgoblin.compiler.types.Type type,
+ org.zwobble.hobgoblin.compiler.sources.Source source
+) implements org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode {
+ public static org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator.EQUALS, org.zwobble.hobgoblin.compiler.ast.typed.TypedNumberLiteralNode.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.typed.TypedNumberLiteralNode.arbitrary().build(), org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryType(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource());
+ }
+
+ public record Builder(
+ org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator operator,
+ org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode left,
+ org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode right,
+ org.zwobble.hobgoblin.compiler.types.Type type,
+ org.zwobble.hobgoblin.compiler.sources.Source source
+ ) implements org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode.Builder {
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode build() {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode(operator, left, right, type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withOperator(org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator operator) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left, right, type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withLeft(org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode left) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left, right, type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withLeft(org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode.Builder left) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left.build(), right, type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withRight(org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode right) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left, right, type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withRight(org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode.Builder right) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left, right.build(), type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withType(org.zwobble.hobgoblin.compiler.types.Type type) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left, right, type, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder(operator, left, right, type, source);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperator.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperator.java
new file mode 100644
index 0000000..85d39ca
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperator.java
@@ -0,0 +1,13 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.typed;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator imports
+
+public enum TypedBinaryOperator {
+ EQUALS
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedExpressionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedExpressionNode.java
index bda7235..887b2b4 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedExpressionNode.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedExpressionNode.java
@@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.ast.typed;
// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode imports
// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode imports
-public sealed interface TypedExpressionNode permits org.zwobble.hobgoblin.compiler.ast.typed.TypedMemberAccessNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedNumberLiteralNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedReferenceNode {
+public sealed interface TypedExpressionNode permits org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedMemberAccessNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedNumberLiteralNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedReferenceNode {
public interface Builder {
public org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode build();
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
index 2727c8f..aceb8e1 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
@@ -705,8 +705,8 @@ public class TypeChecker {
TypeCheckerNamespaceContext context
) {
return switch (expression) {
- case UntypedBinaryOperationNode _ -> {
- throw new UnsupportedOperationException("TODO");
+ case UntypedBinaryOperationNode binaryOperation -> {
+ yield typeCheckBinaryOperation(binaryOperation, context);
}
case UntypedCallNode _ -> {
@@ -731,6 +731,37 @@ public class TypeChecker {
};
}
+ private static TypedExpressionNode typeCheckBinaryOperation(
+ UntypedBinaryOperationNode untyped,
+ TypeCheckerNamespaceContext context
+ ) {
+ var left = typeCheckExpression(untyped.left(), context);
+ var right = typeCheckExpression(untyped.right(), context);
+
+ var operator = switch (untyped.operator()) {
+ case EQUALS -> {
+ if (left.type().equals(NativeTypes.INT_32) && right.type().equals(NativeTypes.INT_32)) {
+ yield TypedBinaryOperator.EQUALS;
+ } else {
+ throw new UnsupportedBinaryOperationError(
+ untyped.operator(),
+ left.type(),
+ right.type(),
+ untyped.source()
+ );
+ }
+ }
+ };
+
+ return new TypedBinaryOperationNode(
+ operator,
+ left,
+ right,
+ left.type(),
+ untyped.source()
+ );
+ }
+
static TypeLevelValue evalExpression(
UntypedExpressionNode expression,
TypeCheckerNamespaceContext context
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/errors/UnsupportedBinaryOperationError.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/errors/UnsupportedBinaryOperationError.java
new file mode 100644
index 0000000..997d49c
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/errors/UnsupportedBinaryOperationError.java
@@ -0,0 +1,36 @@
+package org.zwobble.hobgoblin.compiler.typechecker.errors;
+
+import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedBinaryOperator;
+import org.zwobble.hobgoblin.compiler.errors.SourceError;
+import org.zwobble.hobgoblin.compiler.sources.Source;
+import org.zwobble.hobgoblin.compiler.types.Type;
+
+public class UnsupportedBinaryOperationError extends SourceError {
+ private final UntypedBinaryOperator operator;
+ private final Type left;
+ private final Type right;
+
+ public UnsupportedBinaryOperationError(
+ UntypedBinaryOperator operator,
+ Type left,
+ Type right,
+ Source source
+ ) {
+ super("Binary operation " + left.describe() + " " + operator + " " + right.describe() + " is not supported", source);
+ this.operator = operator;
+ this.left = left;
+ this.right = right;
+ }
+
+ public UntypedBinaryOperator operator() {
+ return operator;
+ }
+
+ public Type left() {
+ return left;
+ }
+
+ public Type right() {
+ return right;
+ }
+}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNodeMatcher.java
new file mode 100644
index 0000000..4d533fa
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedBinaryOperationNodeMatcher.java
@@ -0,0 +1,65 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.typed;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher imports
+
+public final class TypedBinaryOperationNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher isTypedBinaryOperationNode() {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>> submatchers;
+
+ private TypedBinaryOperationNodeMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>> submatchers
+ ) {
+ this.submatchers = submatchers;
+ }
+
+ public org.zwobble.precisely.MatchResult match(java.lang.Object actual) {
+ return this.toMatcher().match(actual);
+ }
+
+ public org.zwobble.precisely.TextTree describe() {
+ return this.toMatcher().describe();
+ }
+
+ private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() {
+ return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher withOperator(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator> operator) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("operator", org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode::operator, (org.zwobble.precisely.Matcher) operator));
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode> left) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode::left, (org.zwobble.precisely.Matcher) left));
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedExpressionNode> right) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode::right, (org.zwobble.precisely.Matcher) right));
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.Type> type) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode::type, (org.zwobble.precisely.Matcher) type));
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNode::source, (org.zwobble.precisely.Matcher) source));
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher body
+}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerBinaryOperationTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerBinaryOperationTests.java
new file mode 100644
index 0000000..22584d8
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerBinaryOperationTests.java
@@ -0,0 +1,65 @@
+package org.zwobble.hobgoblin.compiler.typechecker;
+
+import org.junit.jupiter.api.Test;
+import org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperator;
+import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedBinaryOperationNode;
+import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedBinaryOperator;
+import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedReferenceNode;
+import org.zwobble.hobgoblin.compiler.builtins.NativeTypes;
+import org.zwobble.hobgoblin.compiler.sources.NullSource;
+import org.zwobble.hobgoblin.compiler.typechecker.errors.UnsupportedBinaryOperationError;
+import org.zwobble.hobgoblin.compiler.types.NamespaceName;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.zwobble.hobgoblin.compiler.ast.typed.TypedBinaryOperationNodeMatcher.isTypedBinaryOperationNode;
+import static org.zwobble.hobgoblin.compiler.ast.typed.TypedReferenceNodeMatcher.isTypedReferenceNode;
+import static org.zwobble.precisely.AssertThat.assertThat;
+import static org.zwobble.precisely.Matchers.equalTo;
+
+public class TypeCheckerBinaryOperationTests {
+ @Test
+ public void whenLeftAndRightOperandsAreNumbersThenEqualityOperationTypeChecks() {
+ var untyped = UntypedBinaryOperationNode.arbitrary()
+ .withOperator(UntypedBinaryOperator.EQUALS)
+ .withLeft(UntypedReferenceNode.arbitrary().withName("a"))
+ .withRight(UntypedReferenceNode.arbitrary().withName("b"))
+ .build();
+ var globalContext = TypeCheckerContextArb.globalContext();
+ var namespaceName = NamespaceName.of("App");
+ var namespaceContext = globalContext.enterNamespace(namespaceName);
+ namespaceContext.declare("a", NativeTypes.INT_32, NullSource.INSTANCE);
+ namespaceContext.declare("b", NativeTypes.INT_32, NullSource.INSTANCE);
+
+ var typed = TypeChecker.typeCheckExpression(untyped, namespaceContext);
+
+ assertThat(typed, isTypedBinaryOperationNode()
+ .withOperator(equalTo(TypedBinaryOperator.EQUALS))
+ .withLeft(isTypedReferenceNode().withName(equalTo("a")))
+ .withRight(isTypedReferenceNode().withName(equalTo("b")))
+ .withType(equalTo(NativeTypes.INT_32))
+ );
+ }
+
+ @Test
+ public void whenLeftAndRightOperandsAreDifferentTypesThenEqualityOperationFailsToTypeCheck() {
+ var untyped = UntypedBinaryOperationNode.arbitrary()
+ .withOperator(UntypedBinaryOperator.EQUALS)
+ .withLeft(UntypedReferenceNode.arbitrary().withName("a"))
+ .withRight(UntypedReferenceNode.arbitrary().withName("b"))
+ .build();
+ var globalContext = TypeCheckerContextArb.globalContext();
+ var namespaceName = NamespaceName.of("App");
+ var namespaceContext = globalContext.enterNamespace(namespaceName);
+ namespaceContext.declare("a", NativeTypes.INT_32, NullSource.INSTANCE);
+ namespaceContext.declare("b", NativeTypes.STRING, NullSource.INSTANCE);
+
+ var error = assertThrows(
+ UnsupportedBinaryOperationError.class,
+ () -> TypeChecker.typeCheckExpression(untyped, namespaceContext)
+ );
+
+ assertThat(error.operator(), equalTo(UntypedBinaryOperator.EQUALS));
+ assertThat(error.left(), equalTo(NativeTypes.INT_32));
+ assertThat(error.right(), equalTo(NativeTypes.STRING));
+ }
+}