I was trying to refactor this for a dialyzer error that seemed like it was mostly benign, but then I realized there may be a logic error here which (surprisingly) neither the compiler nor dialyzer picked up. Follow this logic:
timeout() returns a non-nil value
a Task is launched calling handle_notify/3
If the Task yields in time, we have the case statement
The task yielded a value! {:ok, {:ok, new_state}} -> {:noreply, state} ... but we returned the old state anyway just like if the Task didn't yield in time? Why?
https://github.com/whitfin/cachex/blob/5b8983ef670539337373aac3fc6b5772ecfe9735/lib/cachex/hook.ex#L165-L182
I was trying to refactor this for a dialyzer error that seemed like it was mostly benign, but then I realized there may be a logic error here which (surprisingly) neither the compiler nor dialyzer picked up. Follow this logic:
{:ok, {:ok, new_state}} -> {:noreply, state}
... but we returned the old state anyway just like if the Task didn't yield in time? Why?