diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/contracts.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/contracts.scrbl index e2b4723e38..895efc43f4 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/contracts.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/contracts.scrbl @@ -1509,24 +1509,24 @@ The @racket[define-struct/contract] form only allows a subset of the (make-salmon #f 'pacific) ]} -@defform[(invariant-contract contract-expr expr)]{ - Establishes an invariant of @racket[expr], determined by @racket[contract-expr]. +@defform[(invariant-assertion invariant-expr expr)]{ + Establishes an invariant of @racket[expr], determined by @racket[invariant-expr]. - Unlike other ways to attach contracts to values, an - @racket[invariant-contract] does not establish a boundary - between two parties. Instead, it simply puts the contract - on the value, treating the module containing the - @racket[invariant-contract] expression as the party to be blamed - for any violations of the contract. + Unlike the specification of a contract, an + @racket[invariant-assertion] does not establish a boundary + between two parties. Instead, it simply attaches a logical assertion + to the value. Because the form uses contract machinery to check the + assertion, the surround module is treated as the party to be blamed + for any violations of the assertion. - This means, for example, that the contract is checked on + This means, for example, that the assertion is checked on recursive calls, when an invariant is used on the right-hand - side of a definition. + side of a definition: @examples[#:eval furlongs->feet-eval (define furlongss->feets - (invariant-contract + (invariant-assertion (-> (listof real?) (listof real?)) (λ (l) (cond diff --git a/racket/collects/racket/contract/private/base.rkt b/racket/collects/racket/contract/private/base.rkt index 0628b7acc0..6ff693328c 100644 --- a/racket/collects/racket/contract/private/base.rkt +++ b/racket/collects/racket/contract/private/base.rkt @@ -3,7 +3,7 @@ (provide contract (rename-out [-recursive-contract recursive-contract]) current-contract-region - invariant-contract) + invariant-assertion) (require (for-syntax racket/base syntax/name syntax/srcloc) racket/stxparam @@ -89,7 +89,7 @@ (procedure-rename new-val vs-name)])] [else new-val]))) -(define-syntax (invariant-contract stx) +(define-syntax (invariant-assertion stx) (syntax-case stx () [(_ ctc e) (quasisyntax/loc stx diff --git a/racket/collects/racket/contract/region.rkt b/racket/collects/racket/contract/region.rkt index d3d97774aa..2b4d92590d 100644 --- a/racket/collects/racket/contract/region.rkt +++ b/racket/collects/racket/contract/region.rkt @@ -4,7 +4,7 @@ define/contract with-contract current-contract-region - invariant-contract) + invariant-assertion) (require (for-syntax racket/base racket/struct-info