From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Abou Samra Newsgroups: gmane.lisp.guile.user Subject: Re: Source location behavior differs in REPL and script? Date: Sun, 24 Jul 2022 14:54:06 +0200 Message-ID: <0e4ee011-93d2-3719-51db-f2e8f4ea9f15@abou-samra.fr> References: <8929ae87-e67f-e538-8c42-ee537fac8a55@abou-samra.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11767"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jul 24 14:54:27 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFb7r-0002tX-MS for guile-user@m.gmane-mx.org; Sun, 24 Jul 2022 14:54:27 +0200 Original-Received: from localhost ([::1]:39518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFb7q-0000mt-67 for guile-user@m.gmane-mx.org; Sun, 24 Jul 2022 08:54:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFb7e-0000mj-J4 for guile-user@gnu.org; Sun, 24 Jul 2022 08:54:14 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.133]:53193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFb7c-0004wD-T7 for guile-user@gnu.org; Sun, 24 Jul 2022 08:54:14 -0400 Original-Received: from [192.168.1.128] ([82.65.251.18]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.168]) with ESMTPSA (Nemesis) id 1Mz9pT-1nKlTF3Im3-00wFJz for ; Sun, 24 Jul 2022 14:54:10 +0200 Content-Language: en-US In-Reply-To: <8929ae87-e67f-e538-8c42-ee537fac8a55@abou-samra.fr> X-Provags-ID: V03:K1:+9OsJnfiRBylYDy/pWxbw/i12HS5wtevBFU2KSwWzapnYCJG5cr RLGWW7OAfV92xcRCH5HiePW6S9+Gz6tMWazdtLiiCpPityXdjPqWE+lFU1Luk7idzQZzfIx Qkzw/O8cHX7FmZcMWKIuMIOB0wRFMF+7CqtzqpkFvZBkELCxPcN4oD3BJUJ8/pzCj5io/Tm nAbkytj4e5AA2eEBsanNQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:N1UzLJCpsfc=:GCQ3fnG6z5JfVdl++9ofpX 85dkYJOCtNQsjjkzxiiz3RJEtFvapqxFzwmmIX0PF/bE17VPgvddpwEiuyK++9S4yVkJ1X9pv jeA7W2vVToeLeVtBmH+TboA3+ZZ2ccSQbMGJUwC+3YpLdjWQwEYXUgX/edysVM0ZN+/ujqAGR iyC5usq2KGPfhN/tDIC3sQxJyul5s24DuWtKX2vXu+BBzrEVnmlpbSO2eiFWw8QUWSi6HK9hv mJLdQhTQ/TV/9y7bFRVwhziVwfkzj4f69flLqzIqyo4yy5zfRSJP/Tjti3NSaUHsLuMWn1jf+ Qtuv0D+eD1hcjpTGDfDcAWoiUMUJ/7CpwC8wgxwc69bbh69dzpwVoQXyOmL3oUFy7ZkfISaai VtqIgjLEV5/hGH+YwxLHuGatsh2U+VIKOVJ9yNcfXWhVWa+7CcPqgOEHadCSrUlBM+uS9ZuNS OKrSETKy4KDKJg/2JWnnNoLpNcWG48l8zjdU7Ax2wPTcuaR9g95RJlLpH9mJ/AzCgxFgp0lLh 4oN09FnDnIwTs0Jvk7uopu2bOq8SfCi1KQM/irORcvtosHALxvxp3t/9n0N1rYAFdBtlMDaZ5 yd4uHGePjwHO6ajof9o+FXV5aVFF0i0A3XtXlsvkjQFI83xAEQKkxDESIeh9icYUGUiEFHxjH BBOXAQ4Swxh7e+dxrWSLmjpXJKAKjr9bpI61FhmrvWXQk+uxYmfInHagiI59V1q2R17DWKA/Y dota2wzKjU2vez7EJiOicrPHMFxVuJsIGLXUWg== Received-SPF: none client-ip=212.227.126.133; envelope-from=jean@abou-samra.fr; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18452 Archived-At: Le 24/07/2022 à 14:26, Jean Abou Samra a écrit : > Hi, > > 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. > > Example: > > (use-modules (system base compile)) > > (define code-str >   " > (begin >   (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 >   (call-with-input-string >    code-str >    (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: > Oops > > > When I put it in tests.scm and run "guile3.0 tests.scm", > the error is > > fake.scm:15:4: In procedure func1: > Oops > > > When I put it in a LilyPond file, the result is > > Oops > > (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 > workaround? Well, 10 minutes later, I have my answer. Both the REPL and LilyPond use catch to be robust against errors, printing the backtraces but not exiting themselves. I need to investigate if there is a way to get the location when catching an exception. Sorry for the noise, Jean