Subject: Re: bug#62053: Guile compiler is unable to compile tiny program

From: <[email-masked]>
Date: Wed, 8 Mar 2023 17:41:19 +0100

On Wed, Mar 08, 2023 at 02:07:56PM +0300, var-vniiaes--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language wrote:
> 
> Guile compiler is unable to compile tiny program:
>  
> (define (fn l)
>     (define (ok l)
>        (or (and (pair? l) l)
>            (error "list is empty")))
>     (cons (reverse (car l)) (ok l)))
>  
> amaya@picasso:~/tmp/guile-3.0.9
> $ ../prefix/bin/guile ~/tmp/guile-compiler-bug.scm
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling /home/amaya/tmp/guile-compiler-bug.scm
> ;;; WARNING: compilation of /home/amaya/tmp/guile-compiler-bug.scm failed:
> ;;; not found 22
>  
> Compiler reports confusing message here: `not found 22’.   

Bizarre. Can confirm 

tomas@trotzki:~/foo$ vim buggy.scm
  tomas@trotzki:~/foo$ guile buggy.scm 
  ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
  ;;;       or pass the --no-auto-compile argument to disable.
  ;;; compiling /home/tomas/foo/buggy.scm
  ;;; /home/tomas/foo/buggy.scm:2:0: warning: possibly unbound variable `#{   }#'
  ;;; /home/tomas/foo/buggy.scm:3:0: warning: possibly unbound variable `#{      }#'
  ;;; /home/tomas/foo/buggy.scm:4:0: warning: possibly unbound variable `#{          }#'
  ;;; WARNING: compilation of /home/tomas/foo/buggy.scm failed:
  ;;; not found 25

  tomas@trotzki:~/foo$ guile --version
  guile (GNU Guile) 3.0.8.57-bc3b1
  Copyright (C) 2022 Free Software Foundation, Inc.

  License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

(so in my case it's 25 instead of 22). Interestingly, my version also
produces warnings about possibly unbound variables). If I enter the
code line by line into a repl, I also get a "not found 22".

Interestingly, if I add a call to fn to the end of that snippet
(e.g. (fn '(a b))), the "not found" disappears. The unbound var
warnings stay.

Cheers
-- 
t