# Error with base/generic function calls

**URL:** <https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174>\
**Category:** General Usage\
**Created:** [August 3, 2020, 7:36am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174 "2020-08-03T07:36:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ConnectedSystems](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/connectedsystems/32/16815_2.png) [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Post date:** [August 3, 2020, 7:36am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174/1 "2020-08-03T07:36:41Z")

</div>

I’m having trouble with functions seemingly disappearing as I get an `UndefVarError`.

Specifically, in my case, the `subtypes()` function, although I think I encountered the same issue with `DataFrames.valuecols()`.

I have no idea what’s going on.

If I run the below in the REPL, it works fine as expected:

```julia
using DataFrames

@info subtypes(DataFrame)
# [Info: Type[]

function get_subtypes()
    return subtypes(DataFrame)
end

@info get_subtypes()
# [Info: Type[]

```

If I put it into a file and include it, both calls works as expected

```bash
julia> include("src/subtypes.jl")
[Info: Type[]
[Info: Type[]

```

But running the file directly doesn’t work:

```bash
$ julia --project=. src/subtypes.jl
┌ Error: Exception while generating log record in module Main at c:\programs\ownCloud\projects\example_error\src\subtypes.jl:3
│ exception =
│ UndefVarError: subtypes not defined
│ Stacktrace:
│ [1] top-level scope at logging.jl:331
│ [2] include(::Function, ::Module, ::String) at .\Base.jl:380
│ [3] include(::Module, ::String) at .\Base.jl:368
│ [4] exec_options(::Base.JLOptions) at .\client.jl:296
│ [5] _start() at .\client.jl:506

```

And in running the actual piece of code I am working on, a call to `subtypes()` at the top level works, but the second call within a function errors out with no message:

```bash
[Info: Type[]
ERROR:

```

This is happening on Windows 10, for both v1.5.0 and v1.4.0

EDIT: Experiencing same issue on Linux, Julia 1.5.0

Does anyone know what’s happening here?  
I swear this was working a few weeks ago (I’m working with Julia on and off)

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [August 3, 2020, 8:47am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174/2 "2020-08-03T08:47:08Z")

</div>

Add a  
`using InteractiveUtils`  
to your subtypes.jl  
It seems this stdlib package is auto-imported in the REPL but not in general. I didn’t found anything described in the docs, but it seems to be self explaining as the name of the package is “ **Interactive** Utilities”.

I think it is worth a PR or a issue in [Issues · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues) but I don’t know how often this happens and if it is really worth it. As far as I follow discussions here people do not stumble very often over this.

---

<div class="post-metadata">

**Author:** ![ConnectedSystems](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/connectedsystems/32/16815_2.png) [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Post date:** [August 3, 2020, 10:22am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174/3 "2020-08-03T10:22:26Z")

</div>

@oheil thanks for your response

Now that you’ve explained where it was moved, I found [this post](https://discourse.julialang.org/t/why-has-subtypes-function-been-moved-to-module-interactiveutils-v0-7-0/11975/6) which made me think about what might be the Julian way of doing what I wanted.

In my case it was simple enough to re-conceptualize so that the following was suitable:

```nohighlight
a isa CustomType
# true

# the above also works for subtypes of CustomType

```

So my direct issue is solved but I’m kind of annoyed that the documentation, with example, didn’t explicitly mention this ([Reflection and introspection · The Julia Language](https://docs.julialang.org/en/v1/devdocs/reflection/#Subtypes-1)). I feel the info is buried.

But anyway, thanks again.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [August 3, 2020, 10:33am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174/4 "2020-08-03T10:33:33Z")

</div>

> [@ConnectedSystems](#):
>
> I’m kind of annoyed that the documentation, with example, didn’t explicitly mention this ([Reflection and introspection · The Julia Language](https://docs.julialang.org/en/v1/devdocs/reflection/#Subtypes-1)). I feel the info is buried.

Feel free to edit the documentation (link to edit is at the top of the page in the right upper corner) and create a PR (it’s straight forward and the option for a PR is presented automatically if I remember correctly). Of course it is not guaranteed that the PR is accepted. Link to this discussion for the motivation of the PR.

---

<div class="post-metadata">

**Author:** ![ConnectedSystems](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/connectedsystems/32/16815_2.png) [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Post date:** [August 9, 2020, 12:28am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174/5 "2020-08-09T00:28:42Z")

</div>

Thanks again @oheil, I’ve started a PR here:

[https://github.com/JuliaLang/julia/pull/36971](https://github.com/JuliaLang/julia/pull/36971)
