assert now gives source information when available.
This commit is contained in:
parent
5aa6e1b05e
commit
959082d12d
|
@ -1 +1 @@
|
||||||
1560
|
1561
|
||||||
|
|
|
@ -634,6 +634,7 @@
|
||||||
[apply i r ba se]
|
[apply i r ba se]
|
||||||
[asin i r ba se]
|
[asin i r ba se]
|
||||||
[assert i r ba]
|
[assert i r ba]
|
||||||
|
[assertion-error ]
|
||||||
[assertion-violation i r ba]
|
[assertion-violation i r ba]
|
||||||
[atan i r ba se]
|
[atan i r ba se]
|
||||||
[boolean=? i r ba]
|
[boolean=? i r ba]
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
compile-r6rs-top-level boot-library-expand
|
compile-r6rs-top-level boot-library-expand
|
||||||
null-environment scheme-report-environment
|
null-environment scheme-report-environment
|
||||||
interaction-environment
|
interaction-environment
|
||||||
ellipsis-map)
|
ellipsis-map assertion-error)
|
||||||
(import
|
(import
|
||||||
(except (rnrs)
|
(except (rnrs)
|
||||||
environment environment? identifier?
|
environment environment? identifier?
|
||||||
|
@ -1435,8 +1435,10 @@
|
||||||
(lambda (stx)
|
(lambda (stx)
|
||||||
(syntax-match stx ()
|
(syntax-match stx ()
|
||||||
((_ expr)
|
((_ expr)
|
||||||
(bless `(unless ,expr
|
(let ([pos (or (expression-position stx)
|
||||||
(assertion-violation 'assert "assertion failed" ',expr)))))))
|
(expression-position expr))])
|
||||||
|
(bless
|
||||||
|
`(unless ,expr (assertion-error ',expr ',pos))))))))
|
||||||
|
|
||||||
(define endianness-macro
|
(define endianness-macro
|
||||||
(lambda (stx)
|
(lambda (stx)
|
||||||
|
@ -3843,20 +3845,32 @@
|
||||||
(assertion-violation 'bound-identifier=? "not an identifier" y))
|
(assertion-violation 'bound-identifier=? "not an identifier" y))
|
||||||
(assertion-violation 'bound-identifier=? "not an identifier" x))))
|
(assertion-violation 'bound-identifier=? "not an identifier" x))))
|
||||||
|
|
||||||
(define (extract-position-condition x)
|
(define (make-source-condition x)
|
||||||
(define-condition-type &source-information &condition
|
(define-condition-type &source-information &condition
|
||||||
make-source-condition source-condition?
|
make-source-condition source-condition?
|
||||||
(file-name source-filename)
|
(file-name source-filename)
|
||||||
(character source-character))
|
(character source-character))
|
||||||
(if (stx? x)
|
(if (pair? x)
|
||||||
|
(make-source-condition (car x) (cdr x))
|
||||||
|
(condition)))
|
||||||
|
|
||||||
|
(define (extract-position-condition x)
|
||||||
|
(make-source-condition (expression-position x)))
|
||||||
|
|
||||||
|
(define (expression-position x)
|
||||||
|
(and (stx? x)
|
||||||
(let ([x (stx-expr x)])
|
(let ([x (stx-expr x)])
|
||||||
(if (annotation? x)
|
(and (annotation? x)
|
||||||
(let ([src (annotation-source x)])
|
(annotation-source x)))))
|
||||||
(if (pair? src)
|
|
||||||
(make-source-condition (car src) (cdr src))
|
(define (assertion-error expr pos)
|
||||||
(condition)))
|
(raise
|
||||||
(condition)))
|
(condition
|
||||||
(condition)))
|
(make-assertion-violation)
|
||||||
|
(make-who-condition 'assert)
|
||||||
|
(make-message-condition "assertion failed")
|
||||||
|
(make-irritants-condition (list expr))
|
||||||
|
(make-source-condition pos))))
|
||||||
|
|
||||||
(define syntax-error
|
(define syntax-error
|
||||||
(lambda (x . args)
|
(lambda (x . args)
|
||||||
|
|
Loading…
Reference in New Issue