Improve errors for forbidden ops on weak sets

Forbidden set operations on weak sets produced slightly confusing error
messages:

    > (define s (weak-set))
    > (set-add s 42)
    ; set-add:
    ; expected: (not/c set-mutable?)
    ; given mutable set: (weak-set)
    ; argument position: 1st
    > (set-mutable? s)
    #f

Invoking an operation that required an immutable set gave a message
saying that a `(not/c set-mutable?)` was expected, but a `weak-set` is
not recognized by `set-mutable?`, which only recognizes mutable sets
with strongly-held keys. Changing `set-mutable?` to recognize weak sets
seems undesirable.

This patch changes the error message so that the above example produces
the following error:

    > (define s (weak-set))
    > (set-add s 42)
    ; set-add:
    ; expected: (not/c (or/c set-mutable? set-weak?))
    ; given mutable set: (weak-set)
    ; argument position: 1st
This commit is contained in:
Anish Athalye 2021-02-09 05:40:22 -05:00 committed by Sam Tobin-Hochstadt
parent 0137c1c545
commit c07e9cde09

View File

@ -682,7 +682,7 @@
"given ~a: ~e\n"
"argument position: 1st")
method-name
(if immut "(not/c set-mutable?)" "set-mutable?")
(if immut "(not/c (or/c set-mutable? set-weak?))" "(or/c set-mutable? set-weak?)")
(if immut "mutable set" "immutable set")
s)
(current-continuation-marks))))