Menu ▾ ▴

#5874 An error during translate() breaks later translations of functions with free variables

None
open
nobody
translate (11)
5
3 days ago
3 days ago
No

By Claude:

When translate() fails with an error, the local variables of the function being translated stay marked as bound in the translator. A later translation then treats a free variable of the same name as a local one, and the translated function fails with a Lisp error:

(%i1) m(x) ::= error("boom")$
(%i2) f(u) := block([nn], mode_declare(nn, fixnum), m(nn))$
(%i3) errcatch(translate(f));
boom
(%o3) []
(%i4) h(v) := [v, nn]$
(%i5) translate(h)$
(%i6) h(1);
Maxima encountered a Lisp error:

 The variable $NN is unbound.

The interpreted h(1) returns [1, nn], and so should the translated one. The state persists for the rest of the session. A failed translation of a function calling tellsimp() leaves even x marked as bound this way. Seen on master and 5.40.0 with SBCL.

Discussion


Log in to post a comment.