# How to see stack trace from macro expansion error

**URL:** <https://discourse.julialang.org/t/how-to-see-stack-trace-from-macro-expansion-error/132900>\
**Category:** General Usage\
**Created:** [October 6, 2025, 12:04am UTC](https://discourse.julialang.org/t/how-to-see-stack-trace-from-macro-expansion-error/132900 "2025-10-06T00:04:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [October 6, 2025, 12:04am UTC](https://discourse.julialang.org/t/how-to-see-stack-trace-from-macro-expansion-error/132900/1 "2025-10-06T00:04:43Z")

</div>

Hello I get Zygote error:

```julia-auto
Compiling Tuple{typeof(myfunc), OrderedDict{Symbol, Any}}: ArgumentError: array must be non-empty

[1] macro expansion
    @ C:\Users\default.LAPTOP-HMRU58MH\.julia\packages\Zygote\55SqB\src\compiler\interface2.jl:0 [inlined]
[2] _pullback(ctx::Zygote.Context{false}, f::typeof(ff), args::OrderedDict{Symbol, Any})
    @ Zygote C:\Users\default.LAPTOP-HMRU58MH\.julia\packages\Zygote\55SqB\src\compiler\interface2.jl:81

```

```julia-auto
Julia Version 1.12.0-rc3
Commit 7522b24014 (2025-09-26 07:42 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × AMD Ryzen 7 8845HS w/ Radeon 780M Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 16 default, 1 interactive, 16 GC (on 16 virtual cores)
Environment:
  JULIA_DEBUG = Main
  JULIA_PKG_PRECOMPILE_AUTO = 0
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1
  JULIA_NUM_THREADS = 16

```

The `macro expansion` points to `[1] interface2.jl:0` (non-existent line 0). `[2] interface2.jl:81` is some eval expression which generated the code that erred whose whole stack trace I can’t see. Is there a way of seeing a more helpful stack trace from the macro?

I’ve used Zygote for many years and encountered this after refactoring previously working code.  
Yes I checked the obvious for empty arrays on my end but it’s not it. Bizarrely I can (sometimes) get parts of it to work by renaming functions or changing their order so IDK if it’s a weird world age problem. Errs on both Julia 11 and 12. It’s rather convoluted to produce a MWE..

---

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [October 9, 2025, 1:27am UTC](https://discourse.julialang.org/t/how-to-see-stack-trace-from-macro-expansion-error/132900/2 "2025-10-09T01:27:35Z")

</div>

Solved: error due to GPUArrays.AllocCache() and GPUArrays.@cached though they were on a branch that isn’t even executed during AD. Bizarre.

As a general feature request, it’d be nice to see generated code in macro expansion errors 🙂
