walk the cdr of a form as a list, not as a form
The walker offered walk-fn every cdr as well as every form, so the tail (t) of (fn g () t) read as a call to a macro named t: any function whose return type or parameter type shared a name with a macro expanded that tail and died on the macro's arity.
This commit is contained in:
@@ -394,6 +394,21 @@ compiles."
|
||||
(fn f ((c (closure ((int)) int))) int (return (g c)))"
|
||||
"g(c)")))
|
||||
|
||||
;; The walker offered WALK-FN the cdr of every form as well as the
|
||||
;; form, so the tail (t) of (fn g () t) read as a call to a macro
|
||||
;; named t, and any function returning a type that shared a name
|
||||
;; with a macro died on that macro's arity.
|
||||
(test-group "a form's tail is not a form"
|
||||
(test-assert "a return type may share a name with a macro"
|
||||
(emits? "(defmacro (t x) 1)(typedef t int)(fn g () t (return 1))"
|
||||
"t g (void)"))
|
||||
(test-assert "so may a parameter's type"
|
||||
(emits? "(defmacro (u x) 1)(typedef u int)(fn g ((a u)) void (return))"
|
||||
"void g (u a)"))
|
||||
(test-assert "and the macro still expands where it is called"
|
||||
(emits? "(defmacro (t x) x)(fn g () int (return (t 7)))"
|
||||
"return 7")))
|
||||
|
||||
;; a macro body reads types as lists, so the srfi-1 accessors are in
|
||||
;; scope beside the type database
|
||||
(test-group "macro list accessors"
|
||||
|
||||
Reference in New Issue
Block a user