-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let-values can bind variables incorrectly #504
Comments
After macro expansion, the following code segment is generated:
In the inner call-with-values, the last argument should be x$1228$1243, while the last argument for the outer call-with-values should be x$1215$1226 |
Still investigating: if I change one of the identifiers in the templates in the syntax-rules for let-values, then it seems to work.
|
The renaming of variables in the previous comment obviously does not work in general. The problem is that free variables "x" are introduced in the template, but they may already be bound in the scope surrounding the macro evaluation. Here is a small example:
The easiest fix is perhaps to just set let-values == let*-values. |
Apologies for the many replies! This is probably issue #431 and not really about let-values. |
No need for apologies @yorickhardy - thanks for raising this issue and working through it! |
When I tried the ray tracer https://git.sr.ht/~jakob/lisp-raytracer-zoo/tree/master/item/r7rs-raytracer.scm with cyclone, I see the error
Patching r7rs-raytracer.scm with (i.e. replacing let-values) yields a working ray tracer:
The problem seems to be that
(let-values (((shape position) (...))) ...)
binds the same value to shape and position (both are bound to a shape). I tested this a bit more in the ray tracer code and the value bound to the first variable is bound also to all subsequent variables -- but I cannot reproduce it yet in a small example (small examples all seemed to work as expected). I also looked at the implementation of let-values and could not find any bugs, sorry!The text was updated successfully, but these errors were encountered: