Better (load) call error checking

This commit is contained in:
2020-12-31 17:46:51 -07:00
parent cc84067b36
commit 5dd47261da

View File

@@ -97,7 +97,10 @@ class Kiss {
#end
switch (nextExp.def) {
// (load... ) is the specialest of forms because it calls build() again and those fields need to be merged
case CallExp({pos: _, def: Symbol("load")}, [{pos: _, def: StrExp(otherKissFile)}]):
case CallExp({pos: _, def: Symbol("load")}, loadArgs):
nextExp.checkNumArgs(1, 1, "(load \"[file]\")");
switch (loadArgs[0].def) {
case StrExp(otherKissFile):
var filePath = Path.join([loadingDirectory, otherKissFile]);
if (!k.loadedFiles.exists(filePath)) {
var loadedFields = Kiss.build(filePath, k, false);
@@ -106,6 +109,9 @@ class Kiss {
}
k.loadedFiles[filePath] = true;
}
default:
throw CompileError.fromExp(loadArgs[0], "only argument to load should be a string literal");
}
default:
var field = readerExpToField(nextExp, k);
if (field != null) {