case fails for vectors with negative numbers

Description

The last case should return true like the other,

Real life example that triggered this:

Explaination: This is caused by `case` using `hashCode` instead of hashEq for hash comparisons (when not wrapped in a vector, the comparison is direct) and the fact that negative integers and negative longs hash differently while positive ones hash identical.
Porposal: Make `case` use hasheq instead of hashCode

Patch: 0001-switch-to-hasheq-for-case.patch

Prescreened by: Alex Miller

Environment

OSX

Activity

Show:
Nicola Mometto
November 27, 2017, 4:38 PM

Patch is a straightforward search and replace, apart from line 30 of the diff which is quite tricky: I believe using `h` there was a bug in the previous impl that never survaced because hashCode on positive integers is idempotent. But since hashEq isn't double hashing would cause collision nodes never to match.

Alex Miller
October 1, 2019, 8:54 PM

Just thinking through this from a backwards compatibility point of view with respect to the change in Compiler... hashes are computed both in the case macro and by the AOT compiled code. Trying to think through whether a combination of new core lib with old AOT class would create an issue. I guess everything that needs to sync up is in the class file so it should be fine, but this is a case we should test manually to double-check.

Alex Miller
October 1, 2019, 9:26 PM

Test fails w/current patch:

Nicola Mometto
October 7, 2019, 1:39 PM

I couldn’t repro this failure on a clean clojure checkout + this patch

Alex Miller
October 7, 2019, 2:12 PM

I just reset my env and can't repro it either. I must have had something out of whack, sorry about that.

Assignee

Unassigned

Reporter

import

Labels

Approval

Prescreened

Patch

Code and Test

Affects versions

Priority

Critical