diff --git a/rhombus/private/veneer.rkt b/rhombus/private/veneer.rkt index a262a13a0..f352a239a 100644 --- a/rhombus/private/veneer.rkt +++ b/rhombus/private/veneer.rkt @@ -271,7 +271,7 @@ #f dot-provider-rhss parent-dot-providers #`(name name-extends tail-name - #,(and (syntax-e #'check?) #'name?) name-convert + name?/checked name-convert constructor-name name-instance name-ref name-of #f #f dot-provider-name indirect-static-infos @@ -390,29 +390,36 @@ (list (if converter? #`(define name-convert - (let ([name? ann.predicate]) - (lambda (v who) - #,(cond - [(syntax-e #'check?) - #`(if (and #,(if super? #`(#,super? v) #t) - (name? v)) - (if who - v - (lambda () v)) - (if who - (raise-binding-failure who "argument" v '#,all-ann-str) - #f))] - [else - #`(if who - v - (lambda () v))])))) + #,(cond + [(syntax-e #'check?) + #`(let ([name? ann.predicate]) + (let ([name? (lambda (v) + #,(if super? + #`(and (#,super? v) + (name? v)) + #`(name? v)))]) + (lambda (v who) + (if (name? v) + (if who + v + (lambda () v)) + (if who + (raise-binding-failure who "argument" v '#,all-ann-str) + #f)))))] + [else + #`(lambda (v who) + (if who + v + (lambda () v)))])) #`(define name? #,(cond [(syntax-e #'check?) #`(let ([name? ann.predicate]) (let ([name? (lambda (v) - (and #,(if super? #`(#,super? v) #t) - (name? v)))]) + #,(if super? + #`(and (#,super? v) + (name? v)) + #`(name? v)))]) (case-lambda [(v) (name? v)] [(v who) (unless (name? v) diff --git a/rhombus/tests/veneer.rhm b/rhombus/tests/veneer.rhm index e792ddb50..9122040e2 100644 --- a/rhombus/tests/veneer.rhm +++ b/rhombus/tests/veneer.rhm @@ -162,3 +162,58 @@ check: check: IdSet2("oops") ~is "oops" "oops" :: IdSet2 ~is "oops" + +// check evaluation/expansion of annotations in veneers +check: + veneer Unchecked(this :~ Any.of(error("should not get here"))) + ~completes + +check: + veneer Unchecked(this :~ Any.of(error("should not get here"))): + converter + ~completes + +check: + veneer Checked(this :: Any.of(error("should get here"))) + #void + ~throws "should get here" + +check: + veneer Checked(this :: Any.of(error("should get here"))): + converter + #void + ~throws "should get here" + +check: + ~eval + import rhombus/meta open + expr.macro 'meta_error($msg)': + syntax_meta.error(msg) + veneer Unchecked(this :~ Any.of(meta_error("should not get here"))) + ~completes + +check: + ~eval + import rhombus/meta open + expr.macro 'meta_error($msg)': + syntax_meta.error(msg) + veneer Unchecked(this :~ Any.of(meta_error("should not get here"))): + converter + ~completes + +check: + ~eval + import rhombus/meta open + expr.macro 'meta_error($msg)': + syntax_meta.error(msg) + veneer Checked(this :: Any.of(meta_error("should get here"))) + ~throws "should get here" + +check: + ~eval + import rhombus/meta open + expr.macro 'meta_error($msg)': + syntax_meta.error(msg) + veneer Checked(this :: Any.of(meta_error("should get here"))): + converter + ~throws "should get here"