Simon Tournier <zimon.touto...@gmail.com> writes: > Hi, > > Some of us are not always happy with the Guix/Guile error reporting. As > discussed at the Guix Days, maybe the best strategy to improve the > situation is to report small examples that we can work on. Therefore, > here one that I have just hit today when working on Julia.
Here's a more minimal example from the guile-user mailing list 5 years ago, that doesn't touch any Guix code at all: https://lists.gnu.org/archive/html/guile-user/2020-03/msg00030.html For convenience, I'm pasting it below (including a missing line from the backtrace that was mentioned in a reply): --8<---------------cut here---------------start------------->8--- Hello, consider the following piece of code: $ cat test.scm (use-modules (ice-9 regex)) (define (change text) (regexp-substitute #f (string-match "string" text) 'pre "something" 0 'post)) (define (main) (change "there will be no match")) (main) When I run the script, I get a backtrace: $ guile -s test.scm Backtrace: In ice-9/boot-9.scm: 1736:10 8 (with-exception-handler _ _ #:unwind? _ # _) In unknown file: 7 (apply-smob/0 #<thunk 2237960>) In ice-9/boot-9.scm: 718:2 6 (call-with-prompt _ _ #<procedure default-prompt-handle…>) In ice-9/eval.scm: 619:8 5 (_ #(#(#<directory (guile-user) 225ef00>))) In ice-9/boot-9.scm: 2806:4 4 (save-module-excursion _) 4351:12 3 (_) In ice-9/ports.scm: 550:4 2 (call-with-output-string _) In ice-9/boot-9.scm: 260:13 1 (for-each #<procedure 290ed20 at ice-9/regex.scm:143:1…> …) In ice-9/regex.scm: 64:2 0 (_ _) ice-9/regex.scm:64:2: In procedure vector-ref: Wrong type argument in position 1 (expecting vector): #f Why do I not see the exact place where the problem is? Why are there underscores instead? Why do I not even see that the error originated in test.scm? I can't find any explanation about this in the manual. While this code was extracted from a bigger program and it's obvious where the problem is, it was super hard to figure it out in the original program. Because the backtrace actually doesn't even point in the right place, it's quite useless in my opinion. Am I doing anything wrong? I use guile 3.0.1. Regards, -- Jan Synacek Software Engineer, Red Hat --8<---------------cut here---------------end--------------->8--- As Jan points out, one would at least expect the backtrace to tell us that the error comes from the `regexp-substitute` function in test.scm. Instead we have to guess that, by looking at 64:2 in ice-9/regex.scm [1]. The fact that most of the useful information is replaced by underscores and ellipses doesn't help either (apparently this is a compiler optimization issue, as the rest of the thread discusses; and apparently nobody knows how to turn said optimizations off in Guix [2]). It would certainly be helpful to improve error handling in Guix, but I don't think that's the root cause of our problems. If this is the situation even with a tiny Guile test program, then it would seem that there are more fundamental problems to be addressed in Guile itself and its standard libraries. Until that's done, everything else will feel like a band-aid, IMHO. [1] https://lists.gnu.org/archive/html/guile-user/2020-03/msg00042.html [2] https://yhetil.org/guix/87sepwrpbl....@gmail.com/