Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display additional stack trace for r7rs#import error v2 #971

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hamayama
Copy link
Contributor

@Hamayama Hamayama commented Jan 3, 2024

<<本件は、急いでマージする必用はありません。>>

#528 を更新したものです。

現状の HEAD に移植しました。

これは、import 中にエラーが発生すると、(スタックトレースが捨てられるために)
エラーの発生箇所が分からないという問題に対応したものです。

import 中にエラーが発生した場合に、
(最初の1個分だけ) スタックトレースを保存し、
現状のスタックトレースの後ろに表示します。

ただ、アドホックであまり良くないかもしれない。

(あと、GAUCHE_SPLIT_STACK と機能がかぶっている気もしましたが、
ちょっとよく分かりませんでした)

<補足情報>
この改造をしないでデバッグする場合、
import を load に置き変えるという方法があります。
(load だと (実行時の読み込みになり) スタックトレースが捨てられません。)
ただ、ライブラリ内でさらに import を使っていた場合には、
エラーにつながるすべての import を load に置き換える必要があります。

<テスト結果>
テストデータを、以下に作成しました。
https://gist.github.com/Hamayama/937320546e05b4d889f35cfae50a6310

変更前

> gosh -I. library-test.scm
*** ERROR: invalid application: (() ())
    While loading "./library1.sld" at line 5
    While compiling "./library2.sld" at line 1: (define-library (library2) (import (scheme base) (library1)))
    While loading "./library2.sld" at line 7
    While compiling "./library-test.scm" at line 9: (import (library2))
    While loading "./library-test.scm" at line 9
Stack Trace:
_______________________________________
  0  (%require feature)
  1  (%map1c pass1 (cdr form) cenv)
  2  (pass1 program cenv)
  3  (eval s #f)
  4  (with-error-handler (lambda (e) (cond (else (let1 e2 (if (con ...
  5  (load-from-port (if ignore-coding port (open-coding-aware-por ...

変更後

> gosh -I. library-test.scm
*** ERROR: invalid application: (() ())
    While loading "./library1.sld" at line 5
    While compiling "./library2.sld" at line 1: (define-library (library2) (import (scheme base) (library1)))
    While loading "./library2.sld" at line 7
    While compiling "./library-test.scm" at line 9: (import (library2))
    While loading "./library-test.scm" at line 9
Stack Trace:
_______________________________________
  0  (%require feature)
  1  (%map1c pass1 (cdr form) cenv)
  2  (pass1 program cenv)
  3  (eval s #f)
  4  (with-error-handler (lambda (e) (cond (else (let1 e2 (if (con ...
  5  (load-from-port (if ignore-coding port (open-coding-aware-por ...
Stack Trace on Error:
_______________________________________
  0  (() '())
        at "./library1.scm":3
  1  (define reverse-rconj (case-lambda (() '()) ((lst) lst) ((lst ...
        at "./library1.scm":1
  2  (eval s #f)
  3  (with-error-handler (lambda (e) (cond (else (let1 e2 (if (con ...
  4  (load-from-port (if ignore-coding port (open-coding-aware-por ...
  5  (%require feature)
  6  (%map1c pass1 (cdr form) cenv)
  7  (%map1c pass1 body newenv)
  8  (pass1 program cenv)
  9  (eval s #f)
 10  (with-error-handler (lambda (e) (cond (else (let1 e2 (if (con ...
 11  (load-from-port (if ignore-coding port (open-coding-aware-por ...
 12  (%require feature)
 13  (%map1c pass1 (cdr form) cenv)
 14  (pass1 program cenv)
 15  (eval s #f)
 16  (with-error-handler (lambda (e) (cond (else (let1 e2 (if (con ...
 17  (load-from-port (if ignore-coding port (open-coding-aware-por ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant