Skip to content

Invalid hash value for nested arrays #3884

@flash-gordon

Description

@flash-gordon

Environment

It seems that every version of jruby starting from at least 9k-pre1 has the following behavior.

Expected Behavior

2.3.1 :001 > [1, [1, []]].hash
 => 2397343324588010773
2.3.1 :002 > [2, [2, []]].hash
 => 4238421788679554352

Actual Behavior

jruby-9.1.0.0 :086 > [1, [1, []]].hash
 => 0
jruby-9.1.0.0 :087 > [2, [2, []]].hash
 => 0

We expect things to work in dry-validation because we use caching based on a hash of AST which in order is represented by a deeply nested array. The issue leads to returning the same result based on different outputs which surprises a lot.

Original values that you can use for testing a fix:

jruby-9.1.0.0 :001 > [[:and, [[:val, [:predicate, [:key?, [:age]]]], [:key, [:age, [:predicate, [:lt?, [23]]]]]]]].hash
 => 8481884717
jruby-9.1.0.0 :002 > [[:and, [[:val, [:predicate, [:key?, [:foo]]]], [:key, [:foo, [:predicate, [:lt?, [23]]]]]]]].hash
 => 8481884717

I don't know what exactly is going wrong but I tried to provide as minimal failing case as I could and it would supercool to have this fixed because you guys are doing a great job and having a support for jruby really matters for us, thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions