# Invalid redefinition error for parametric type defined inside macro call

**URL:** https://discourse.julialang.org/t/invalid-redefinition-error-for-parametric-type-defined-inside-macro-call/10424
**Category:** General Usage
**Tags:** bug, macros, parametric-types
**Created:** [April 19, 2018, 1:26am UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-parametric-type-defined-inside-macro-call/10424 "2018-04-19T01:26:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ntezak](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@ntezak](https://discourse.julialang.org/u/ntezak)
#### Post date: [April 19, 2018, 1:26am UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-parametric-type-defined-inside-macro-call/10424/1 "2018-04-19T01:26:56Z")

</div>

Hi folks, been using Julia happily on and off since v0.2, here is a thing I keep stumbling over:

```julia
julia> macro passthru(ex)
       ex
       end
@passthru (macro with 1 method)

julia> @passthru type MyType{T}
              args::Vector{T}
              end

julia> @passthru type MyType{T}
              args::Vector{T}
              end
ERROR: invalid redefinition of constant MyType

```

The same thing works fine with non-parametric types:

```julia
julia> @passthru type MyType2
              args::Vector
              end

julia> @passthru type MyType2
              args::Vector
              end

```

In words, when I create parametric type inside a macro several times, Julia fails to detect that the redefinition agrees with the prior definition and throws an error.  
OTOH without the macro call this works fine:

```julia
julia> type MyType3{T}
              args::Vector{T}
              end

julia> type MyType3{T}
              args::Vector{T}
              end

```

Is this a bug or am I misunderstanding something?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [April 19, 2018, 2:03am UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-parametric-type-defined-inside-macro-call/10424/2 "2018-04-19T02:03:15Z")

</div>

Look at the result of `macroexpand`. You likely need to escape the input expression.

```julia
julia> macro passthru(ex)
           esc(ex)
       end

julia> @passthru type MyType{T}
           args::Vector{T}
       end

julia> @passthru type MyType{T}
           args::Vector{T}
       end

```
