#108 "undefined variable" error k too shallow


The code

(lambda (m e)
(let ([val 1])
(putprop 'foo val)
(e val)))
(lambda ()
(+ foo 1)))

should return 2 on the first and all subsequent
invocations. However, it returns 1 on the first invocation.

It appears that the error continuation of the
"undefined variable" error is the (+ ...) expression
rather than the "foo" expression.


  • Matthias Radestock

    Logged In: YES

    This behaviour may be due to "foo" being considered an
    immediate expression by AppExp, which results in the error
    occuring in the AppExp itself, rather than a sub-ordinate

  • Scott G. Miller

    Scott G. Miller - 2005-01-04

    Logged In: YES

    Unfortunately, it can't really be any 'deeper'. The free
    reference is an immediate expression of the AppExp of the
    addition, so there really isn't any other stack frame. What
    we should probably change is the manual, to make it clear
    that the implementation doesn't guarantee that each
    conceptual stack frame is realized by an actual stack frame.

    The alternative is to deintegrate the immediates, which
    would be unacceptable from a performance standpoint.

  • Matthias Radestock

    Logged In: YES

    Why can't we de-integrate the immediates when an error occurs?

    Basically, if we don't do something about this problem then
    invoking an error k might as well not be permitted since it
    is impossible to determine what point the k returns to.

  • Scott G. Miller

    Scott G. Miller - 2005-01-16

    Logged In: YES

    We can't do it easily, since it requires FreeReferenceExp to
    know which other uExp is hosting it, and cloning that uExp
    with itself replaced with some non-immediate version, then
    pushing that expression onto the stack. It *almost* fits
    within the optimistic inlining framework I just wrote, but
    not really since we don't want to permanently de-inline the
    free reference, since the user may fix the undefined error,
    leaving the code crippled for all references to that variable.

    In short, it would be pretty ugly.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks