Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eqv?: incorrect behavior with uninterned symbols #709

Open
Zipheir opened this issue Jan 29, 2025 · 0 comments · May be fixed by #710
Open

eqv?: incorrect behavior with uninterned symbols #709

Zipheir opened this issue Jan 29, 2025 · 0 comments · May be fixed by #710

Comments

@Zipheir
Copy link

Zipheir commented Jan 29, 2025

When invoked on one or more uninterned symbols, eqv? gives a different answer from symbol=?:

(define usym (string->uninterned-symbol "x"))

(eqv? usym 'x) => #t

(symbol=? usym 'x) => #f

In general, eqv? returns #t for uninterned symbols with the same name:

(eqv? (string->uninterned-symbol "x") (string->uninterned-symbol "x"))
  => #t
jpellegrini added a commit to jpellegrini/STklos that referenced this issue Jan 29, 2025
uninterned, `eqv?` may consider both to be the same. With this
patch, `eqv?` won't deal with uninterned symbols, rteating them
always as "different from whatever else".

This is the same behavior as Chez, Chicken, Gambit, Gauche, MIT.
(Bigloo, Kawa, Chibi do not have string->uninterned-symbol).

The change is:

1. In `eqv?`, check for hard equality (with `==`) so if one of the
   symbols is uninterned, the result is `#f`
2. Since we're at it, rewrite `symbol=?` so it will not accept
   non-symbol arguments (so its behavior will be the same as
   `string=?`

So now:
(eqv? (string->uninterned-symbol "x")
      (string->uninterned-symbol "x"))       => #f

This should fix egallesio#709
jpellegrini added a commit to jpellegrini/STklos that referenced this issue Jan 29, 2025
Currently, if one of the symbols is uninterned, `eqv?` may consider
both to be the same. With this patch, `eqv?` won't deal with
uninterned symbols, rteating them always as "different from whatever
else".

This is the same behavior as Chez, Chicken, Gambit, Gauche, MIT.
(Bigloo, Kawa, Chibi do not have string->uninterned-symbol).

The change is:

1. In `eqv?`, check for hard equality (with `==`) so if one of the
   symbols is uninterned, the result is `#f`
2. Since we're at it, rewrite `symbol=?` so it will not accept
   non-symbol arguments (so its behavior will be the same as
   `string=?`

So now:
(eqv? (string->uninterned-symbol "x")
      (string->uninterned-symbol "x"))       => #f

This should fix egallesio#709
@jpellegrini jpellegrini linked a pull request Jan 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant