From 33f360c9cf952a2490b444329a691b14b8a551aa Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sat, 21 Jan 2023 13:33:25 +0000 Subject: [PATCH] Fixed a way to have a bad type, thanks neuf! --- source/interpreter.c | 8 ++++++++ source/scope.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/source/interpreter.c b/source/interpreter.c index ace9ab7..06d4ad5 100644 --- a/source/interpreter.c +++ b/source/interpreter.c @@ -527,6 +527,14 @@ static Literal parseTypeToValue(Interpreter* interpreter, Literal type) { } } + //BUGFIX: make sure it actually is a type + if (!IS_TYPE(type)) { + interpreter->errorOutput("Bad type encountered: "); + printLiteralCustom(type, interpreter->errorOutput); + interpreter->errorOutput("\n"); + //TODO: would be better to return an int here... + } + return type; } diff --git a/source/scope.c b/source/scope.c index 745c1e2..eefb266 100644 --- a/source/scope.c +++ b/source/scope.c @@ -239,6 +239,10 @@ bool declareScopeVariable(Scope* scope, Literal key, Literal type) { return false; } + if (!IS_TYPE(type)) { + return false; + } + //store the type, for later checking on assignment setLiteralDictionary(&scope->types, key, type);