macroExpand expand type aliases in lambda
This commit is contained in:
@@ -947,4 +947,12 @@ class Helpers {
|
||||
return result.withPosOf(exp);
|
||||
}
|
||||
|
||||
public static function expandTypeAliases(exp:ReaderExp, k:KissState) {
|
||||
return switch (exp.def) {
|
||||
case TypedExp(path, innerExp):
|
||||
TypedExp(replaceTypeAliases(path, k), innerExp).withPosOf(exp);
|
||||
default:
|
||||
expMap(exp, expandTypeAliases.bind(_, k));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -669,7 +669,7 @@ class SpecialForms {
|
||||
|
||||
map["lambda"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||
var b = wholeExp.expBuilder();
|
||||
b.callSymbol("lambda", [args[0]].concat([for (exp in args.slice(1)) Kiss.macroExpand(exp, k)]));
|
||||
b.callSymbol("lambda", [Helpers.expandTypeAliases(args[0], k)].concat([for (exp in args.slice(1)) Kiss.macroExpand(exp, k)]));
|
||||
};
|
||||
|
||||
return map;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
(defAlias &ident Stream kiss.Stream)
|
||||
(defAlias &type Stream kiss.Stream)
|
||||
|
||||
(defMacro makeExample [expression &body b]
|
||||
`(let [normal ,(printExp expression)
|
||||
@@ -17,4 +18,9 @@
|
||||
(normal null)
|
||||
(expanded null))
|
||||
|
||||
(makeExample
|
||||
(lambda [:Stream s] (Stream.fromString ""))
|
||||
(normal null)
|
||||
(expanded null))
|
||||
|
||||
)
|
Reference in New Issue
Block a user