Skip to content

Commit

Permalink
Correct type checking for returned function values
Browse files Browse the repository at this point in the history
  • Loading branch information
schwalbe-t authored Jan 28, 2023
1 parent 59e31d9 commit 2a38be9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
2 changes: 1 addition & 1 deletion currant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion currant/types/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2a38be9

Please sign in to comment.