[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Source location behavior differs in REPL and script?

From: Jean Abou Samra
Subject: Source location behavior differs in REPL and script?
Date: Sun, 24 Jul 2022 14:26:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0


For context, I'm trying to fix issues with source locations
from embedded Scheme code in LilyPond. Essentially, with
Guile 2.2, errors are displayed without any source location
info because the evaluator doesn't provide them. The compiler
does, so I'm investigating whether we can use it.

So far, I've been experimenting in the REPL, and tearing my
hair because I couldn't get locations to work. My test started
to become inconvenient to modify in the REPL at some point,
so I switched to putting that code in a .scm file. To my
great surprise, that made locations suddenly work.


(use-modules (system base compile))

(define code-str
  (debug-disable 'backtrace)
  (define (func1 x)
    (func2 x)
    (func2 x)
    (func2 x))

  (define (func2 x)
    (display (func3 x))
    (write (func3 x))
    (map write (func3 x)))

  (define (func3 x)
    (error \"Oops\"))

  (func1 #f))

(define code-synt
   (lambda (port)
     (set-port-filename! port "fake.scm")
     (read-syntax port))))

(compile code-synt)

When I paste this in the REPL, the given error is

ice-9/boot-9.scm:1685:16: In procedure raise-exception:

When I put it in tests.scm and run "guile3.0 tests.scm",
the error is

fake.scm:15:4: In procedure func1:

When I put it in a LilyPond file, the result is


(without any location info at all).

Does anyone have a clue about what causes these differences?
Is it expected? Should I report it as a bug? Also, is there a


reply via email to

[Prev in Thread] Current Thread [Next in Thread]