# Using @code\_warntype to inspect my module functions

**URL:** https://discourse.julialang.org/t/using-code-warntype-to-inspect-my-module-functions/74901
**Category:** General Usage
**Created:** [January 20, 2022, 4:42am UTC](https://discourse.julialang.org/t/using-code-warntype-to-inspect-my-module-functions/74901 "2022-01-20T04:42:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [January 20, 2022, 4:42am UTC](https://discourse.julialang.org/t/using-code-warntype-to-inspect-my-module-functions/74901/1 "2022-01-20T04:42:51Z")

</div>

Hello!

I am wondering what or how is the best way to use `@code_warntype` to inspect my code for type instabilities. To give you some context, I am working in a script file (`.jl`) and doing `using MyCustomModule` at the top to bring in some structs and methods I have written. Also, I am using VsCode with the Julia extension.

I want to step through the methods I have defined and try to find places where I might have created type instabilities. What I have tried thus far to do is have a line like this in my script (not all methods are exported) and run it interactively by highlighting it and pressing Shift+Enter. The output is sent to the REPL. .

```julia
@code_warntype MyCustomModule.SomeMethod

```

Regardless of which method I use the macro on though, I seem to only ever get back the following (below) and I assume I must be doing something wrong.

```julia
Variables
  #self#::Core.Const(getproperty)
  x::Module
  f::Symbol

Body::Any
1 ─ %1 = Base.getfield(x, f)::Any
└── return %1

```

I would appreciate any tips on how I could use this correctly.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [January 20, 2022, 4:46am UTC](https://discourse.julialang.org/t/using-code-warntype-to-inspect-my-module-functions/74901/2 "2022-01-20T04:46:29Z")

</div>

You have to call the function. `@code_warntype foo(1,2)`. Also you might want to try `JET.@report_opt f(1,2)`.

---

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [January 21, 2022, 12:58am UTC](https://discourse.julialang.org/t/using-code-warntype-to-inspect-my-module-functions/74901/3 "2022-01-21T00:58:59Z")

</div>

> [@jzr](#):
>
> You have to call the function. `@code_warntype foo(1,2)` . Also you might want to try `JET.@report_opt f(1,2)` .

Ah okay - Thank you, and also I did not know about `JET.jl`. I will definitely check that out.

So my problem now is that some of my functions are nested in other functions. I was hoping I could enter the top function via the debugger and then run `@code_warntype NestedFunction(Inputs)` from the debugger console while inside my top level function but that doesn’t seem to work.

---

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [January 21, 2022, 1:13am UTC](https://discourse.julialang.org/t/using-code-warntype-to-inspect-my-module-functions/74901/4 "2022-01-21T01:13:09Z")

</div>

Actually I take that back. At least for the function I am currently trying, `@code_warntype` seems to evaluate fine but it returns nothing. I wonder if that means my function is too complex.
