# Type name clashes

**URL:** <https://discourse.julialang.org/t/type-name-clashes/13689>\
**Category:** General Usage\
**Created:** [August 18, 2018, 9:57pm UTC](https://discourse.julialang.org/t/type-name-clashes/13689 "2018-08-18T21:57:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [August 18, 2018, 9:57pm UTC](https://discourse.julialang.org/t/type-name-clashes/13689/1 "2018-08-18T21:57:28Z")

</div>

I just noticed this:

Works:

```julia
module Foo
struct Array end
end

```

Fails with `ERROR: cannot assign variable Core.Array from module Foo`:

```julia
module Foo
dump(Array)
struct Array end
end

```

Is the conclusion that adding a type that is named the same as a type in `Base` is disallowed now? I’m asking because some code in CxxWrap that creates (non-exported) types named e.g. `Array` seems to fail now in 1.0, and I’m wondering if this is because of a new rule or because I am creating the type using the C interface. I also wonder why it only fails in the second case.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [August 18, 2018, 10:26pm UTC](https://discourse.julialang.org/t/type-name-clashes/13689/2 "2018-08-18T22:26:15Z")

</div>

> [@barche](#):
>
> Is the conclusion that adding a type that is named the same as a type in `Base` is disallowed now

No. But you can’t change the meaning of a const symbol after using it.

---

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [August 19, 2018, 7:19am UTC](https://discourse.julialang.org/t/type-name-clashes/13689/3 "2018-08-19T07:19:11Z")

</div>

> [@yuyichao](#):
>
> No. But you can’t change the meaning of a const symbol after using it.

Aha, that’s indeed what causes this. It seems that checking if a symbol is defined already means it is used, currently I use this code:

```c++
jl_datatype_t* existing_datatype(jl_module_t* mod, jl_sym_t* name)
{
  jl_datatype_t* found_dt = (jl_datatype_t*)jl_get_global(mod, name);
  if(found_dt != nullptr && found_dt->name->module == mod)
  {
    return found_dt;
  }
  return nullptr;
}

```

Is there a way to check if a type is defined in a module without having the symbol marked as used? I am doing this check because of precompilation, to see if the type is available from precompilation or if it needs to be created.
