Error: no overload matches 'Probfin.traverse_remaining', from: (DAG::Vertex | Nil)

Hey! When calling the traverse_remaining method:

protected def self.traverse_remaining(
    from vertex : DAG::Vertex,
    visited = Hash(String, Bool).new,
    remaining_dag = Hash(BlockHash, DAG::Vertex).new,
    remaining_parents = Hash(BlockHash, Array(BlockHash)).new(
      ->(hash : Hash(BlockHash, Array(BlockHash)), key : BlockHash) {
        hash[key] = Array(BlockHash).new
      }
    )
  ) : 
  .....

And passing arguments to it:

remaining_chain = self.traverse_remaining from: tolb.branch_root

The compiler throws an error:

Error: no overload matches ‘ProbFin.traverse_remaining’, from: (DAG::Vertex | Nil)

Without having the code to reproduce, I’d have to guess that tolb.branch_root is of type DAG::Vertex? and the method only allows DAG::Vertex. Basically just need to ensure that it’s not nil before calling the method.

I apologize wildly. Full code:

Yea, my initial guess seems to be the problem. Will need to ensure that tolb.branch_root is not nil before calling that method.

EDIT: Or optionally allow that argument to accept nil and handle it within the method.

1 Like