# Subtypes (apparently) not defined within module

**URL:** https://discourse.julialang.org/t/subtypes-apparently-not-defined-within-module/76669
**Category:** General Usage
**Tags:** question, modules
**Created:** [February 18, 2022, 2:40am UTC](https://discourse.julialang.org/t/subtypes-apparently-not-defined-within-module/76669 "2022-02-18T02:40:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aerdely](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aerdely/32/37506_2.png) [@aerdely](https://discourse.julialang.org/u/aerdely)
#### Post date: [February 18, 2022, 2:40am UTC](https://discourse.julialang.org/t/subtypes-apparently-not-defined-within-module/76669/1 "2022-02-18T02:40:11Z")

</div>

I don’t understand why my function `s1type` works as expected but the same code coming from `MyType` module throws a subtypes not defined error. Any thoughts?

```julia
function s1type(T::DataType)
    println("type:\t\t", T)
    println("supertype:\t", supertype(T))
    println("subtypes:\t", subtypes(T))
    return nothing
end

s1type(Real)

module MyType
    export s2type
    function s2type(T::DataType)
        println("type:\t\t", T)
        println("supertype:\t", supertype(T))
        println("subtypes:\t", subtypes(T))
        return nothing
    end
end

using .MyType

s2type(Real) # ERROR: UndefVarError: subtypes not defined

```

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [February 18, 2022, 3:16am UTC](https://discourse.julialang.org/t/subtypes-apparently-not-defined-within-module/76669/2 "2022-02-18T03:16:15Z")

</div>

> [@aerdely](#):
>
> `subtypes`

comes from `InteractiveUtils`, so you need `using InteractiveUtils` inside the module

btw, this is kinda code smell:

> [@aerdely](#):
>
> `s2type(T::DataType)`

though probably fine for this toy application, but irl you want to either don’t annotate (and throw inside the function dynamically) or use `f(::Type{T}) where T` to specialize on all types. long story short `DataType` is a “book keeping” for typing system, we should try not to dispatch with it
