Subject: bug#38486: Compiler does not terminate

From: Zack Marvel <[email-masked]>
Date: Tue, 3 Dec 2019 21:58:00 -0700

Hello,

When compiling the following program, the compiler does not terminate.

(define (find-closest-intersection board)
   (let ((cols (vector-length board))
	(rows (vector-length (vector-ref board 0))))
     (let col-loop ((col 0)
		   (min-distance 999))
       (if (< col cols)
	  (col-loop
	   (1+ col)
	   (let row-loop ((row 0)
			  (min-distance min-distance))
	     (if (< row rows)
		 (row-loop (1+ row) min-distance)
		 min-distance)))
	  min-distance))))

Here is the output of the compiler:

$ guile ~/src/advent-of-code/2019/guile_infinite_loop.scm
;;; note: source file 
/home/zack/src/advent-of-code/2019/guile_infinite_loop.scm
;;;       newer than compiled 
/home/zack/.local/src/guile-2.2.6/cache/guile/ccache/2.2-LE-8-3.A/home/zack/src/advent-of-code/2019/guile_infinite_loop.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/zack/src/advent-of-code/2019/guile_infinite_loop.scm

If I flatten the two loops into one, the program compiles. If I use 
constants instead of vector sizes, it also compiles.

I can produce this behavior with Guile 2.2.4 and 2.2.6. I'm running 
Debian 10 amd64, and I compiled Guile with GCC 8.3.0.

Please let me know if I can provide more information!

Best regards,
Zack Marvel