Hello Matt,
Le mer. 7 août 2019 à 17:20, Matt Jadud <
ma...@jadud.com> a écrit :
>
> Without looking at the code...
>
> Was letrec removed from the language before it gets to this pass? Put another way, the point of the nanopass framework is to grow/shrink/transform the language in a series of steps. As a result, the intermediate languages change from the front to the back. By the point this pass is executed, does letrec still exist in the language?
Indeed letrec was changed previously to only bind lambdas:
(define-language L8
(extends L7)
(Expr (e body)
(- (lambda (x* ...) abody)
(letrec ([x* e*] ...) abody))
(+ le
(letrec ([x* le*] ...) body)))
(LambdaExpr (le)
(+ (lambda (x* ...) abody))))
Mind the "+ le" which says that LambdaExpr can appear as a body of an
Expr. Then then L9 will remove that "le" from Expr:
(define-language L9
(extends L8)
(Expr (e body)
(- le)))
In the remove-anonymous-lambda pass, the matching rule is over Expr:
(define-pass remove-anonymous-lambda : L8 (e) -> L9 ()
(Expr : Expr (e) -> Expr ()
[(lambda (,x* ...) ,[abody])
(let ([t (unique-var 'anon)])
`(letrec ([,t (lambda (,x* ...) ,abody)]) ,t))]))
Which means it only match LambdaExpr that appear as expression.
The bug I was talking about would appear if instead of Expr it was LambdaExpr...
Thanks!