aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-10-29 18:23:36 +0000
committerMichael Williamson <mike@zwobble.org>2023-10-29 18:23:36 +0000
commit5ab307fa798626d7f852ebec65f87e2af7487c53 (patch)
tree731295fdb7980c979db0a1643e9031104adfd82f /src/main/java
parent7bc7dbd5f5d73c1c070ed69af2ab143d7a1c199e (diff)
Infer return type of function expressions properly
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java b/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java
index 15623e98..17cf42a3 100644
--- a/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java
+++ b/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java
@@ -627,13 +627,6 @@ public class TypeChecker {
) {
var typedSignature = typeCheckFunctionSignature(untyped.signature(), context);
- var type = new FunctionType(
- functionSignatureToPositionalParams(typedSignature),
- functionSignatureToNamedParams(typedSignature),
- functionSignatureToEffect(typedSignature),
- functionSignatureToReturnType(typedSignature).orElse(Types.UNIT)
- );
-
var typedBodyResult = typeCheckFunctionBody(
untyped.body(),
typedSignature,
@@ -642,6 +635,13 @@ public class TypeChecker {
var typedBody = typedBodyResult.value();
context = typedBodyResult.context();
+ var type = new FunctionType(
+ functionSignatureToPositionalParams(typedSignature),
+ functionSignatureToNamedParams(typedSignature),
+ functionSignatureToEffect(typedSignature),
+ typedBody.type()
+ );
+
var typed = new TypedFunctionExpressionNode(
typedSignature,
typedBody,