# \[SOLVED\] Unexpected dispatch behavior

**URL:** https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307
**Category:** New to Julia
**Created:** [December 30, 2022, 8:06am UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307 "2022-12-30T08:06:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bombusfragrans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bombusfragrans/32/42685_2.png) [@bombusfragrans](https://discourse.julialang.org/u/bombusfragrans)
#### Post date: [December 30, 2022, 8:06am UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307/1 "2022-12-30T08:06:38Z")

</div>

**question and broken code removed**  
**SOLVED**

---

<div class="post-metadata">

### Author: ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)
#### Post date: [December 30, 2022, 9:49am UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307/2 "2022-12-30T09:49:41Z")

</div>

Please provide a Minimal Working Example (MWE) so that we can run the code and see where it is going wrong. The code you gave is using undefined types and functions, in particular the following are missing:

- `Empty`
- `WithinLength`
- `isfull`
- `_next_circ_idx`

You might also want to read: [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

Anyways, if I define some of the missing pieces like

```julia
struct Empty{T} <: FillingLevel end
struct WithinLength{T} <: FillingLevel end
isfull(cb::CircularBuffer) = cb.tail >= length(cb.queue)-1

```

I get the following error

```julia
julia> push!(cb1,3,4,5)
ERROR: UndefVarError: _next_circ_idx not defined
Stacktrace:
 [1] _push!(::CircularBuffer{Int64}, ::Int64, ::Vararg{Int64})
   @ Main ~/wd/scratch/julia/mwe_bombusfragrans.jl:123
...

```

In the bits of code I have from you `_next_circ_idx` only appears in the definition of `_push`, so to me it seems to work correctly.  
Maybe just try to restart the REPL and run your script again?

---

<div class="post-metadata">

### Author: ![bombusfragrans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bombusfragrans/32/42685_2.png) [@bombusfragrans](https://discourse.julialang.org/u/bombusfragrans)
#### Post date: [December 30, 2022, 11:35am UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307/3 "2022-12-30T11:35:34Z")

</div>

First: thanks for trying. Very sorry! Should have been a working example. My bad.

---

<div class="post-metadata">

### Author: ![bombusfragrans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bombusfragrans/32/42685_2.png) [@bombusfragrans](https://discourse.julialang.org/u/bombusfragrans)
#### Post date: [December 30, 2022, 1:02pm UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307/4 "2022-12-30T13:02:18Z")

</div>

Very sorry again. Should not have happened. Something got really mixed up…

---

<div class="post-metadata">

### Author: ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)
#### Post date: [December 30, 2022, 3:00pm UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307/5 "2022-12-30T15:00:11Z")

</div>

> Very sorry again. Should not have happened.

No worries!  
The PSA above only says that preparing a MWE makes it simpler for others to help.  
But sometimes it can also help yourself solve the problem immediately.  
Also: I am not saying you should not ask questions here, they are always welcome :).

So what solved the issue in the end?

Btw: You would not have needed to delete the question.

---

<div class="post-metadata">

### Author: ![bombusfragrans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bombusfragrans/32/42685_2.png) [@bombusfragrans](https://discourse.julialang.org/u/bombusfragrans)
#### Post date: [January 3, 2023, 6:16am UTC](https://discourse.julialang.org/t/solved-unexpected-dispatch-behavior/92307/6 "2023-01-03T06:16:05Z")

</div>

Sorry, it was not my intention to waste your time! I actually read the PSA and thus the non-working MWE ws a bit embarrassing… should not have happened.  
Not to confuse others I deleted the code.  
I obviously had same serious tunnel vision. a recursion further down caused the unexpected behaviour…
