Fix a case of macroExpandOnly

This commit is contained in:
2023-03-08 07:28:28 -07:00
parent b2aeed2ad0
commit 7dda864a9a

View File

@@ -465,14 +465,14 @@ class Kiss {
public static function readerExpToHaxeExpr(exp, k): Expr { public static function readerExpToHaxeExpr(exp, k): Expr {
return switch (macroExpandAndConvert(exp, k, false)) { return switch (macroExpandAndConvert(exp, k, false)) {
case Right(expr): expr; case Right(expr): expr;
default: throw "macroExpandAndConvert is broken"; case e: throw 'macroExpandAndConvert is broken: ${e}';
}; };
} }
public static function macroExpand(exp, k):ReaderExp { public static function macroExpand(exp, k):ReaderExp {
return switch (macroExpandAndConvert(exp, k, true)) { return switch (macroExpandAndConvert(exp, k, true)) {
case Left(exp): exp; case Left(exp): exp;
default: throw "macroExpandAndConvert is broken"; case e: throw 'macroExpandAndConvert is broken: ${e}';
}; };
} }
@@ -570,7 +570,9 @@ class Kiss {
var expanded = macros[mac](exp, args.copy(), k); var expanded = macros[mac](exp, args.copy(), k);
if (expanded != null) { if (expanded != null) {
convert(expanded); convert(expanded);
} else { } else if (macroExpandOnly) {
Left(None.withPosOf(exp));
} else{
Right(none); Right(none);
}; };
case CallExp({pos: _, def: Symbol(specialForm)}, args) if (specialForms.exists(specialForm) && !macroExpandOnly): case CallExp({pos: _, def: Symbol(specialForm)}, args) if (specialForms.exists(specialForm) && !macroExpandOnly):