Hi Andy,
I ran into the same problem while trying the nanopass framework in Racket and even with your answer it took some tinkering to make it work.
This is not a question, because I did make it work in the end.
I'm just posting my solution and some comments if that can be useful to someone else.
Initially I tried the following, which fails with `cannot auto-generate body for pass with extra return values in: eval-src`.
(define-pass
eval-src : Lsrc (ir) -> * (n)
(Expr : Expr (ir) -> * (n)
(,n n)
((add ,[e0] ,[e1]) (+ e0 e1))
((sub ,[e0] ,[e1]) (- e0 e1))))
I was a bit puzzled by this error because I couldn't figure out what it was trying to auto-generate. It would be nice if the error message said what it was!
In the end I figured I need to add a body expression and it works:
(define-pass
eval-src : Lsrc (ir) -> * (n)
(Expr : Expr (ir) -> * (n)
(,n n)
((add ,[e0] ,[e1]) (+ e0 e1))
((sub ,[e0] ,[e1]) (- e0 e1)))
(Expr ir))
While tinkering before finding the above solution, I found that this works too (without a body expression):
(define-pass
eval-src : Lsrc (ir) -> * ()
(Expr : Expr (ir) -> * ()
(,n n)
((add ,[Expr : -> e0] ,[Expr : -> e1]) (+ e0 e1))
((sub ,[Expr : -> e0] ,[Expr : -> e1]) (- e0 e1))))
However, the following fails with `eval-src: incorrect arguments for Expr in cata in: (Expr : -> e0)`
(define-pass
eval-src : Lsrc (ir) -> * (n)
(Expr : Expr (ir) -> * (n)
(,n n)
((add ,[Expr : -> e0] ,[Expr : -> e1]) (+ e0 e1))
((sub ,[Expr : -> e0] ,[Expr : -> e1]) (- e0 e1)))
(Expr ir))
But the following works:
(define-pass
eval-src : Lsrc (ir) -> * (n)
(Expr : Expr (ir) -> * (n)
(,n (values 0 n))
((add ,[Expr : -> z1 e0] ,[Expr : -> z2 e1]) (values 0 (+ e0 e1)))
((sub ,[Expr : -> z1 e0] ,[Expr : -> z2 e1]) (values 0 (- e0 e1))))
(Expr ir))