diff --git a/source/toy_interpreter.c b/source/toy_interpreter.c index 5f8f47a..0897956 100644 --- a/source/toy_interpreter.c +++ b/source/toy_interpreter.c @@ -2316,7 +2316,6 @@ static void readInterpreterSections(Toy_Interpreter* interpreter) { //change the type to normal interpreter->literalCache.literals[i] = TOY_TO_FUNCTION_LITERAL(bytes, size); - TOY_AS_FUNCTION(interpreter->literalCache.literals[i]).scope = NULL; } } diff --git a/source/toy_scope.c b/source/toy_scope.c index cb15fee..9c2e979 100644 --- a/source/toy_scope.c +++ b/source/toy_scope.c @@ -159,6 +159,10 @@ static bool checkType(Toy_Literal typeLiteral, Toy_Literal original, Toy_Literal return false; } + if (TOY_AS_TYPE(typeLiteral).typeOf == TOY_LITERAL_OPAQUE && !TOY_IS_OPAQUE(value)) { + return false; + } + return true; } @@ -185,7 +189,7 @@ Toy_Scope* Toy_popScope(Toy_Scope* scope) { Toy_Scope* ret = scope->ancestor; - //BUGFIX: when freeing a scope, free the function's scopes manually + //BUGFIX: when freeing a scope, free the functions' scopes manually - I *think* this is related to the closure hack-in for (int i = 0; i < scope->variables.capacity; i++) { //handle keys, just in case if (TOY_IS_FUNCTION(scope->variables.entries[i].key)) { @@ -286,7 +290,7 @@ bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value, } //actually assign - Toy_setLiteralDictionary(&scope->variables, key, value); + Toy_setLiteralDictionary(&scope->variables, key, value); //key & value are copied here Toy_freeLiteral(typeLiteral); Toy_freeLiteral(original); diff --git a/source/toy_scope.h b/source/toy_scope.h index 1c0c683..8f22504 100644 --- a/source/toy_scope.h +++ b/source/toy_scope.h @@ -1,5 +1,6 @@ #pragma once +#include "toy_literal.h" #include "toy_literal_array.h" #include "toy_literal_dictionary.h"