#108 "undefined variable" error k too shallow

open
nobody
None
5
2004-12-11
2004-12-11
No

The code

(with/fc
(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.

Discussion

  • Logged In: YES
    user_id=110070

    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
    FillRibExp.

     
  • Logged In: YES
    user_id=25869

    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.

     
  • Logged In: YES
    user_id=110070

    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.

     
  • Logged In: YES
    user_id=25869

    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.