Subject: Possible Bug: Inconsistent Evaluation Environment

From: Prafulla Giri <[email-masked]>
Date: Wed, 27 Mar 2024 15:46:41 +0000

Hello there,

I have bumped into an interesting issue with GNU Guile 3.0.9 (as shipped via GNU GUIX).

Consider a file -- file1.scm -- with the following definition over-riding the built-in procedure vector-length:

(define (vector-length whatever) "over-ridden")

Now, consider another file -- file2.scm -- which makes use of this over-ridden procedure, the contents of which are:

(load "file1.scm") ; both files are in the same directory
(define (some-procedure whatever) (vector-length whatever))

Now, if one loads file2.scm with guile with:
$ guile -l file2.scm
and in the REPL tries:
>(some-procedure 'anything) ;; this is expected to return "over-ridden"
an error is thrown saying vector-length expects a vector. To make things "curiouser and curiouser"
>(vector-length 'anything) ;; returns "over-ridden", as expected.

As such, it seems that we have a situation where the evaluation environment is somewhat inconsistent.

Interestingly enough, this problem also seems to be there on GNU Guile 2.2.7 as available via GNU Guix.

Chez Scheme 9.5.8 behaves as expected: (some-procedure 'whatever) does return "over-ridden".
Likewise with TinyScheme 1.42, Scheme48 1.9.2, MIT Scheme 11.2 and even GNU Guile 1.8.8 --- all behave as expected and return "over-ridden" after evaluating (some-procedure 'whatever).

The issue does not occur if all the definitions are in the same file, however.

Perhaps this warrants further investigation.