From 2a38be9f36b6d596a8325d6ed4970708cc1c3f78 Mon Sep 17 00:00:00 2001 From: DevTaube <78918080+DevTaube@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:00:18 +0200 Subject: [PATCH] Correct type checking for returned function values --- README.md | 2 +- currant.js | 2 +- currant/types/function.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f50342..96b792c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Currant-Logo](./logo2.png) +![Currant-Logo](./logo.png) Currant is a single-threaded programming language that runs in the browser. It has simple interoperability with JavaScript and can be easily embedded into a webpage: diff --git a/currant.js b/currant.js index dbf7d6a..5a0f02f 100644 --- a/currant.js +++ b/currant.js @@ -1637,7 +1637,7 @@ class CurrantFunction extends CurrantFunctionInterface { this.returnType.setBlock(bodyCopy); resultType = this.returnType.execute(); if(resultType instanceof CurrantVariableReference) resultType = resultType.get(); - if(result.type.constructor !== resultType.get().constructor) + if(!currantCompareTypes(result.type, resultType.get())) throw new Error(`function did not return value of type "${this.returnType.src}"`); } else { let nothingType = new CurrantNothingType(); diff --git a/currant/types/function.js b/currant/types/function.js index 3fe92e9..4275ce9 100644 --- a/currant/types/function.js +++ b/currant/types/function.js @@ -184,7 +184,7 @@ class CurrantFunction extends CurrantFunctionInterface { this.returnType.setBlock(bodyCopy); resultType = this.returnType.execute(); if(resultType instanceof CurrantVariableReference) resultType = resultType.get(); - if(result.type.constructor !== resultType.get().constructor) + if(!currantCompareTypes(result.type, resultType.get())) throw new Error(`function did not return value of type "${this.returnType.src}"`); } else { let nothingType = new CurrantNothingType();