Catch macro expansion errors from builtin macros

This commit is contained in:
2023-03-10 12:21:24 -07:00
parent 8f8c118970
commit 4859ce84b2

View File

@@ -555,7 +555,14 @@ class Kiss {
case CallExp({pos: _, def: Symbol(mac)}, args) if (macros.exists(mac)):
checkNumArgs(mac);
macroUsed = true;
var expanded = macros[mac](exp, args.copy(), k);
var expanded = try {
macros[mac](exp, args.copy(), k);
} catch (error:KissError) {
throw error;
} catch (error:Dynamic) {
throw KissError.fromExp(exp, 'Macro expansion error: $error');
};
if (expanded != null) {
convert(expanded);
} else if (macroExpandOnly) {