# MethodError even when method is in methods(func, types...)

**URL:** <https://discourse.julialang.org/t/methoderror-even-when-method-is-in-methods-func-types/131973>\
**Category:** General Usage\
**Created:** [August 30, 2025, 6:31pm UTC](https://discourse.julialang.org/t/methoderror-even-when-method-is-in-methods-func-types/131973 "2025-08-30T18:31:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejmeitz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ejmeitz/32/45283_2.png) [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Post date:** [August 30, 2025, 6:31pm UTC](https://discourse.julialang.org/t/methoderror-even-when-method-is-in-methods-func-types/131973/1 "2025-08-30T18:31:37Z")

</div>

I have a custom array type, `NDArray` in my own package which is templated on it element type and dimension like a normal Julia Array. The following code works totally fine if I define everything stand alone in the REPL, but fails when I place it inside of the package.

I’ve tried to define the function (as well as `Base.:(*)` and `LinearAlgebra.mul!`):

```julia
function mymultiply(rhs1::NDArray{A, 2}, rhs2::NDArray{B, 2}) where {A,B}
    ...
end

```

but always get a method error:

```julia
julia> mymultiply(a, b)
ERROR: MethodError: no method matching mymultiply(::NDArray{Float32, 2}, ::NDArray{Float32, 2})
Stacktrace:
 [1] top-level scope
   @ REPL[48]:1

```

This is super confusing to me because these are the inputs and the method is visible to`methods`.

```julia
julia> typeof(a)
NDArray{Float32, 2}

julia> typeof(b)
NDArray{Float32, 2}

julia> methods(mymultiply)
# 1 method for generic function "mymultiply" from Main:
 [1] mymultiply(rhs1::NDArray{A, 2}, rhs2::NDArray{B, 2}) where {A, B}
     @ REPL[45]:1

```

---

<div class="post-metadata">

**Author:** ![ejmeitz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ejmeitz/32/45283_2.png) [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Post date:** [August 31, 2025, 7:06pm UTC](https://discourse.julialang.org/t/methoderror-even-when-method-is-in-methods-func-types/131973/2 "2025-08-31T19:06:39Z")

</div>

It turns out that when I constructed my class the dimension was set as an Int32 literal (from a C-API), but when I defined the method it of course uses an Int64 literal. This explains the `MethodError` and why it appears like it should match (Int32 and Int64 print the same in the error)

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [August 31, 2025, 11:18pm UTC](https://discourse.julialang.org/t/methoderror-even-when-method-is-in-methods-func-types/131973/3 "2025-08-31T23:18:18Z")

</div>

> <https://github.com/JuliaLang/julia/issues/57189>
>
> \`Int32(7)\` in \`Val{Int32(7)}\` is shown as a mere \`7\`:
> 
> \`\`\`julia-repl
> julia\> Val{…Int32(7)}
> Val{7}
> \`\`\`
> 
> That's not correct, however, given that \`Val{Int32(7)} != Val{7}\`.
> 
> The misleading printing behavior leads to confusion and complaints such as this one: https://github.com/JuliaArrays/StaticArrays.jl/issues/1233
