# A really not useful backtrace when write wrong macro code?

**URL:** <https://forum.crystal-lang.org/t/a-really-not-useful-backtrace-when-write-wrong-macro-code/4816>\
**Category:** Help & Support\
**Created:** [July 30, 2022, 5:15am UTC](https://forum.crystal-lang.org/t/a-really-not-useful-backtrace-when-write-wrong-macro-code/4816 "2022-07-30T05:15:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [July 30, 2022, 5:15am UTC](https://forum.crystal-lang.org/t/a-really-not-useful-backtrace-when-write-wrong-macro-code/4816/1 "2022-07-30T05:15:09Z")

</div>

Following backtrace happen when i write wrong code when try to play with `avram` migration macro.

e.g. i want to create a companies tables. like this:

```crystal
class CreateCompanies::V20220730045700 < Avram::Migrator::Migration::V1
  def migrate
    # Learn about migrations at: https://luckyframework.org/guides/database/migrations
    create table_for(Company) do
      primary_key id : Int64
      name : String # <= this line should be write like: `add name : String`
      add_timestamps
    end
  end

  def rollback
    drop table_for(Company)
  end
end

```

As you can see, i add wrong code `name : String`, and it’s my fault.

But, The really issue is, crystal complain me a really obscurely backtrace like this:

```auto
 ╰─ $ lucky db.migrate
Crystal::ASTNode#dependencies cannot be nil (NilAssertionError)
  from crystal/src/compiler/crystal/semantic/bindings.cr:3:5 in 'dependencies'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1936:7 in 'bound_to_mod_nil?'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1928:35 in 'reset_nilable_vars'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1587:11 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/call.cr:321:13 in 'codegen_call_with_block'
  from crystal/src/compiler/crystal/codegen/call.cr:32:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/call.cr:73:7 in 'prepare_call_args_non_external'
  from crystal/src/compiler/crystal/codegen/call.cr:57:7 in 'prepare_call_args'
  from crystal/src/compiler/crystal/codegen/call.cr:21:26 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1031:9 in 'codegen_assign'
  from crystal/src/compiler/crystal/codegen/codegen.cr:995:7 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/fun.cr:167:11 in 'codegen_fun'
  from crystal/src/compiler/crystal/codegen/fun.cr:51:3 in 'codegen_fun'
  from crystal/src/compiler/crystal/codegen/fun.cr:8:54 in 'target_def_fun'
  from crystal/src/compiler/crystal/codegen/call.cr:454:12 in 'codegen_call'
  from crystal/src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:839:7 in 'codegen_if_branch'
  from crystal/src/compiler/crystal/codegen/codegen.cr:831:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/fun.cr:167:11 in 'codegen_fun'
  from crystal/src/compiler/crystal/codegen/fun.cr:51:3 in 'codegen_fun'
  from crystal/src/compiler/crystal/codegen/fun.cr:8:54 in 'target_def_fun'
  from crystal/src/compiler/crystal/codegen/call.cr:454:12 in 'codegen_call'
  from crystal/src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1596:11 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1596:11 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:887:15 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/call.cr:321:13 in 'codegen_call_with_block'
  from crystal/src/compiler/crystal/codegen/call.cr:32:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/call.cr:321:13 in 'codegen_call_with_block'
  from crystal/src/compiler/crystal/codegen/call.cr:32:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:1596:11 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:839:7 in 'codegen_if_branch'
  from crystal/src/compiler/crystal/codegen/codegen.cr:831:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/exception.cr:91:7 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/call.cr:321:13 in 'codegen_call_with_block'
  from crystal/src/compiler/crystal/codegen/call.cr:32:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/fun.cr:167:11 in 'codegen_fun'
  from crystal/src/compiler/crystal/codegen/fun.cr:51:3 in 'codegen_fun'
  from crystal/src/compiler/crystal/codegen/fun.cr:8:54 in 'target_def_fun'
  from crystal/src/compiler/crystal/codegen/call.cr:454:12 in 'codegen_call'
  from crystal/src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:436:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:665:9 in 'visit'
  from crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:2279:7 in 'accept'
  from crystal/src/compiler/crystal/codegen/codegen.cr:69:7 in 'codegen'
  from crystal/src/compiler/crystal/codegen/codegen.cr:67:5 in 'codegen:debug:single_module'
  from crystal/src/compiler/crystal/progress_tracker.cr:22:7 in 'codegen'
  from crystal/src/compiler/crystal/compiler.cr:173:16 in 'compile'
  from crystal/src/compiler/crystal/command.cr:309:3 in 'compile'
  from crystal/src/compiler/crystal/command.cr:307:5 in 'compile'
  from crystal/src/compiler/crystal/command.cr:192:5 in 'build'
  from crystal/src/compiler/crystal/command.cr:74:7 in 'run'
  from crystal/src/compiler/crystal/command.cr:51:5 in 'run'
  from crystal/src/compiler/crystal/command.cr:50:3 in 'run'
  from crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from crystal/src/crystal/main.cr:101:7 in 'main'
  from crystal/src/crystal/main.cr:127:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from ../sysdeps/x86_64/start.S:117 in '_start'
  from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

```

Yes, it probably a avram issue, anyway, i report it here, i guess it can be improve from compiler?

I can reproduce it on a kemal + avaram project. for the discuss, can check [here](https://github.com/luckyframework/lucky/discussions/1710)

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [July 30, 2022, 5:27am UTC](https://forum.crystal-lang.org/t/a-really-not-useful-backtrace-when-write-wrong-macro-code/4816/2 "2022-07-30T05:27:14Z")

</div>

> [@zw963](#):
>
> Yes, it probably a avram issue, anyway, i report it here, i guess it can be improve from compiler?

The error does point out:

> Error: you’ve found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: [Issues · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues)

So it’s an odd trace since its a compiler bug and not currently something it handles. Hard to say what the exact issue is w/o creating a reduced example tho. Might also be an existing issue for it.

EDIT: It’s [[ICE] `x : Int32` inside block · Issue #9124 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues/9124)
