Fixed a way to have a bad type, thanks neuf!

This commit is contained in:
2023-01-21 13:33:25 +00:00
parent d3516b4fc9
commit 33f360c9cf
2 changed files with 12 additions and 0 deletions

View File

@@ -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; return type;
} }

View File

@@ -239,6 +239,10 @@ bool declareScopeVariable(Scope* scope, Literal key, Literal type) {
return false; return false;
} }
if (!IS_TYPE(type)) {
return false;
}
//store the type, for later checking on assignment //store the type, for later checking on assignment
setLiteralDictionary(&scope->types, key, type); setLiteralDictionary(&scope->types, key, type);