GNU bug report logs -
#14164
letrec: detect illegal accesses to vars before entering body
Previous Next
Full log
Message #12 received at 14164 <at> debbugs.gnu.org (full text, mbox):
Nikita Karetnikov <nikita <at> karetnikov.org> writes:
> According to the manual [1], this snippet:
>
> (letrec ((a 42)
> (b (+ a 10)))
> (* a b))
>
> should return "Error: unbound variable: a."
The manual doesn't say anything nearly that specific. It says "Note
that while the init expressions may refer to the new variables, they may
not access their values." The R5RS says "it must be possible to
evaluate each <init> without assigning or referring to the value of any
<variable>. If this restriction is violated, then it is an error."
In general, if the manual says you "may not" do something, or if the
R5RS says "it is an error", that means that if you do, the results are
unspecified. It does not constitute a promise to report an error if you
do.
I agree that we should ideally report errors such as this, but this is
not a bug, but rather a wishlist item. Note that generating code that
detects programmer errors such as this may carry a non-trivial runtime
cost, so we might need to provide a distinct compilation mode that
inserts such debugging checks.
This is on my TODO list, but I wouldn't hold your breath :)
Regards,
Mark
This bug report was last modified 12 years and 65 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.