The Crystal Programming Language Forum

Can't dup a Hash(String, String)

Working on reducing this but I thought this trace would be of interest.
I can’t get this to trigger on the library itself, and this snippet comes from a relatively complex class.
I’m on …

Crystal 0.36.0 (2021-01-26)

LLVM: 9.0.1
Default target: x86_64-apple-macosx

Here’s the tail of the trace

In lib/clustering/src/

 253 | @previous_node_versions = node_versions.dup
Error: instantiating 'Hash(String, String)+#dup()'

In /usr/local/Cellar/crystal/0.36.0/src/

 1775 | hash =
Error: wrong number of arguments for 'Hash(String, String)#initialize' (given 0, expected 3)

Can you share the actual code/library? Based on the + in the trace, it feels like they’re doing something non ideal/custom. Otherwise like {"foo" => "bar"}.dup works fine on the playground and stuff.

I replied to this in github. It would be great if these things were discussed in a single place.

For reference: dup and clone failing on hash · Issue #10328 · crystal-lang/crystal · GitHub

1 Like