chibi-scheme
chibi-scheme copied to clipboard
Missing source line information
This might be a side-effect of https://github.com/ashinn/chibi-scheme/issues/837 , although I am not very sure about that.
I have two MWEs:
One:
#!/usr/bin/env chibi-scheme
(import (scheme base))
(define (fun-false . o) #f)
(define (parse-url-into-website-program_name-version url)
(cond ((fun-false) => (lambda o #t))
(else (error "cannot parse file name") (newline))))
(parse-url-into-website-program_name-version "")
Seemingly, everything very simple, and as static as can be. However, the stack trace is like:
ERROR: cannot parse file name
called from <anonymous>
called from <anonymous> on line 1268 of file /usr/share/chibi-scheme/init-7.scm
called from <anonymous> on line 800 of file /usr/share/chibi-scheme/init-7.scm
The script file name is not in the stack trace, which is kind of weird? Well, the function call may be eliminated due to tail recursion, but "error", I guess, can save source line information somewhere?
The other one is :
#!/usr/bin/env chibi-scheme
(import (scheme base))
(define (fun-false . o) #f)
(define (parse-url-into-website-program_name-version url)
(cond ((fun-false) => (lambda o #t))
(else (error "cannot parse file name"))))
(parse-url-into-website-program_name-version "")
And the stack trace is:
ERROR: cannot parse file name
called from <anonymous> on line 1268 of file /usr/share/chibi-scheme/init-7.scm
called from <anonymous> on line 800 of file /usr/share/chibi-scheme/init-7.scm
So the difference is a missing (newline)
, which, I guess, is a syntax error, but having it influence the stack trace is confusing as well.
If that "always failing" procedure is removed, but the erroneous (?) (newline)
is present:
#!/usr/bin/env chibi-scheme
(import (scheme base))
(define (parse-url-into-website-program_name-version url)
(cond (else (error "cannot parse file name") (newline))))
(parse-url-into-website-program_name-version "")
The stack trace is:
ERROR: cannot parse file name
called from parse-url-into-website-program_name-version on line 4 of file ./test-error-file-line-info.scm
called from <anonymous> on line 1268 of file /usr/share/chibi-scheme/init-7.scm
called from <anonymous> on line 800 of file /usr/share/chibi-scheme/init-7.scm
Suddenly we are getting line information correctly!
However, removing that "erroneous" (newline)
removes line information once again:
#!/usr/bin/env chibi-scheme
(import (scheme base))
(define (parse-url-into-website-program_name-version url)
(cond (else (error "cannot parse file name"))))
(parse-url-into-website-program_name-version "")
./test-error-file-line-info.scm
ERROR: cannot parse file name
called from <anonymous> on line 1268 of file /usr/share/chibi-scheme/init-7.scm
called from <anonymous> on line 800 of file /usr/share/chibi-scheme/init-7.scm
Maybe some syntactic expanders "forget" to attach source line information to sexps? Or, maybe, it would be worth attaching source line information to error objects, regardless of the stack trace?