# User-defined type used in a module differs from the original

**URL:** https://discourse.julialang.org/t/user-defined-type-used-in-a-module-differs-from-the-original/100518
**Category:** New to Julia
**Created:** [June 18, 2023, 2:23pm UTC](https://discourse.julialang.org/t/user-defined-type-used-in-a-module-differs-from-the-original/100518 "2023-06-18T14:23:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jodyxha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jodyxha/32/50840_2.png) [@jodyxha](https://discourse.julialang.org/u/jodyxha)
#### Post date: [June 18, 2023, 2:23pm UTC](https://discourse.julialang.org/t/user-defined-type-used-in-a-module-differs-from-the-original/100518/1 "2023-06-18T14:23:44Z")

</div>

I am a newbie with Julia (thigh not with programming in general).  
Asn exercise i wanted to some simple 3D geometry modules.

One module for 3D vectors (`Vec3D`) which includes an overloaded operator “^” for the outer product::

```
function Base.:^(a::Vec3D, b::Vec3D) 
    Vec3D(a.y*b.z - a.z*b.y,   
                a.z+b.x - a.x*b.z,
               a.x*b.y - a.z*b.y)
end

```

I then have module for quaternions (`Quats`)with an operator `^` used for applying a quaternion to a 3D vector:

```
function Base.:^(a::Quat, b::Vec3D) 
    ...
end

```

For this to work, i had to include the file containing the `Vec3D` definitions and import them:

```
include("vectors3d.jl")
import .Vectors3D:Vec3D

```

Now, when in julia i include the two files of he the modules, almost everything works as expected. However i have a problem with the quaternions´ “^”-operator;

```
julia> include("vectors3d.jl")
Main.Vectors3D

julia> include("quats.jl")
Main.quats

julia> using .Vectors3D

julia> using .Quats

julia> a=Vec3D(1,0,0)
Vec3D(1, 0, 0)

julia> q=Quat(0, 0, 0, 1)
Quat(0, 0, 0, 1)

julia> q^a
ERROR: MethodError: no method matching ^(::Quat, ::Vec3D)
Closest candidates are:
    ^(::Quat, ::Main.Quats.Vectors3D.Vec3D) at ~/progs/jl_progs/quats.jl:126
    ^(::Vec3D, ::Vec3D) at ~/progs/jl_progs/vectors3d.jl:50
Stacktrace:
 [1] top-level scope
   @ REPL[8]:1

```

It looks as if the type of the Vec3D i included and used inside the Quat module is seen as a type different from the Vec3D in the Vectors3D module.

When i define the “^”-operator directly in julia, it works perfectly.

How can i convince julia that the Vec3D type used inside the Quatsmodule is the same as the one from the Vectors3D

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [June 18, 2023, 2:55pm UTC](https://discourse.julialang.org/t/user-defined-type-used-in-a-module-differs-from-the-original/100518/2 "2023-06-18T14:55:57Z")

</div>

> [@jodyxha](#):
>
> How can i convince julia that the Vec3D type used inside the Quatsmodule is the same as the one from the Vectors3D

Import it in the Quats module. You can make this module dependent on the other or, maybe better, make both depend on a third that defines the type.
