Better (load) call error checking
This commit is contained in:
@@ -97,7 +97,10 @@ class Kiss {
|
|||||||
#end
|
#end
|
||||||
switch (nextExp.def) {
|
switch (nextExp.def) {
|
||||||
// (load... ) is the specialest of forms because it calls build() again and those fields need to be merged
|
// (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]);
|
var filePath = Path.join([loadingDirectory, otherKissFile]);
|
||||||
if (!k.loadedFiles.exists(filePath)) {
|
if (!k.loadedFiles.exists(filePath)) {
|
||||||
var loadedFields = Kiss.build(filePath, k, false);
|
var loadedFields = Kiss.build(filePath, k, false);
|
||||||
@@ -106,6 +109,9 @@ class Kiss {
|
|||||||
}
|
}
|
||||||
k.loadedFiles[filePath] = true;
|
k.loadedFiles[filePath] = true;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
throw CompileError.fromExp(loadArgs[0], "only argument to load should be a string literal");
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
var field = readerExpToField(nextExp, k);
|
var field = readerExpToField(nextExp, k);
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
|
Reference in New Issue
Block a user