mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 13:37:33 +02:00
Prevent line number info from being added twice
Since we now call error/loc in the macro expander, it is possible we are double-calling it if a macro is also calling it directly to report a syntax error. We need to detect that case and only add location information (line, column, filename) if it has not already been added to the error message.
This commit is contained in:
parent
1670670968
commit
e6d654b4a4
1 changed files with 10 additions and 4 deletions
|
@ -236,18 +236,24 @@
|
|||
(begin
|
||||
(define *source-loc-lis* '())
|
||||
(define (error/loc reason expr . args)
|
||||
;; Does reason already include line/file location info?
|
||||
(define (reason/line-loc? reason)
|
||||
(and (string? reason)
|
||||
(equal? (substring reason 0 9)
|
||||
"(at line ")))
|
||||
(let* ((found (assoc expr *source-loc-lis*))
|
||||
(loc-vec (if found
|
||||
(cdr found) ;; Get value
|
||||
#f))
|
||||
(msg (if loc-vec
|
||||
(msg (if (and loc-vec ;; Have line info
|
||||
(not (reason/line-loc? reason))) ;; Not there yet
|
||||
(string-append
|
||||
"("
|
||||
(vector-ref loc-vec 0)
|
||||
" line "
|
||||
"(at line "
|
||||
(number->string (vector-ref loc-vec 1))
|
||||
", column "
|
||||
(number->string (vector-ref loc-vec 2))
|
||||
" of "
|
||||
(vector-ref loc-vec 0)
|
||||
") "
|
||||
reason)
|
||||
reason)))
|
||||
|
|
Loading…
Add table
Reference in a new issue