raise-syntax-error: fix srcloc reporting on #f as 3rd arg

This commit is contained in:
Matthew Flatt 2015-07-29 11:46:04 -06:00
parent 99f29ce8ee
commit 26158a51d2
2 changed files with 31 additions and 2 deletions

View File

@ -2083,7 +2083,27 @@
(evalx '(module m racket/base (provide e) (define e #'1)))
(evalx '(module n racket/base (require (for-syntax 'm)) (provide s) (define-syntax (s stx) e)))
(evalx '(require 'n))
(err/rt-test (evalx 's) #rx"literal data is not allowed"))
(err/rt-test (evalx 's) (lambda (exn) (regexp-match? #rx"literal data is not allowed" (exn-message exn)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check source-location reporting by `raise-syntax-error`
(let ()
(define (check a0 a1 . args)
(err/rt-test (apply raise-syntax-error #f "oops" a0 a1 args)
(lambda (exn)
(and (exn:fail:syntax? exn)
(regexp-match? (format "^[^:\n]*:~a:~a:"
(or (syntax-line a1)
(syntax-line a0))
(or (syntax-column a1)
(syntax-column a0)))
(exn-message exn))))))
(define stx #'(a b))
(define a-stx (car (syntax-e stx)))
(check stx a-stx)
(check stx #f)
(check #f a-stx))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -2360,7 +2360,16 @@ static void do_wrong_syntax(const char *where,
where,
s, slen,
v, vlen);
} else
} else if (dv)
blen = scheme_sprintf(buffer, blen,
"%t%s%s: %t\n"
" at: %t",
p, plen,
p ? ": " : "",
where,
s, slen,
dv, dvlen);
else
blen = scheme_sprintf(buffer, blen, "%s: %t",
where,
s, slen);