Any ideas how to navigate this error at compile time?
In spec/redis_spec.cr:352:24
352 | messages = redis.xread(
^----
Error: no overload matches 'Redis::Client#xread', count: Int32, block: Time::Span, streams: Hash(String, String)
Overloads are:
- Redis::Client#xread(*, count : Int32 | String | Nil = nil, block : Time::Span | ::Nil = nil, streams : Hash(String, String))
- Redis::Commands::Stream#xread(*, count : Int32 | String | Nil = nil, block : Time::Span | ::Nil = nil, streams : Hash(String, String))
The code it’s referring to is this:
messages = redis.xread(
count: 10,
block: 2.seconds,
streams: {key => "-"},
)
It seems to be telling me:
count
must beInt32 | String | Nil
and it is anInt32
block
must beTime::Span | Nil
and it is aTime::Span
streams
must be aHash(String, String)
and it is aHash(String, String)
I don’t understand how it’s not matching. If I remove the types I’m not using in this spec to constrain it to the types I am using, I still get an error:
In spec/redis_spec.cr:352:24
352 | messages = redis.xread(
^----
Error: no overload matches 'Redis::Client#xread', count: Int32, block: Time::Span, streams: Hash(String, String)
Overloads are:
- Redis::Client#xread(*, count : Int32, block : Time::Span, streams : Hash(String, String))
- Redis::Commands::Stream#xread(*, count : Int32, block : Time::Span, streams : Hash(String, String))
At first I thought that the compiler might be tripping over the fact that the method is defined in the Commands::Stream
mixin which is then overridden in the Client
class to constrain the return type, but that wasn’t it — it does the same if I define it directly on Client
.