crystal
crystal copied to clipboard
Compiler crash when using a TypeDeclaration in the wrong spot
I found this while working on my app. I actually had a typo, but it took me a bit to find it because I kept getting the compile error.
class Migration
macro create(table_name)
Migration.build do
{{ yield }}
end
end
def self.build(&)
with self yield
self
end
create(:users) do
# this was incorrect
name : String
end
end
Crystal::ASTNode#dependencies cannot be nil (NilAssertionError)
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '??'
from /usr/bin/crystal in '__crystal_main'
from /usr/bin/crystal in 'main'
from /usr/lib/libc.so.6 in '??'
from /usr/lib/libc.so.6 in '__libc_start_main'
from /usr/bin/crystal 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
I thought there was an open issue on this already, but searching github for "you've found a bug in the Crystal compiler." only had 1 open issue that was unrelated.
I'm using Crystal 1.10.1, but this happens on 1.11.1 as well.
Reduced:
def foo(&)
yield
end
foo { x : Int32 }
Crystal::ASTNode#dependencies cannot be nil (NilAssertionError)
from src/compiler/crystal/semantic/bindings.cr:3:5 in 'dependencies'
from src/compiler/crystal/codegen/codegen.cr:2013:7 in 'bound_to_mod_nil?'
from src/compiler/crystal/codegen/codegen.cr:2005:35 in 'reset_nilable_vars'
from src/compiler/crystal/codegen/codegen.cr:1657:11 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2413:7 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2402:9 in 'request_value'
from src/compiler/crystal/codegen/call.cr:307:11 in 'codegen_call_with_block'
from src/compiler/crystal/codegen/call.cr:32:9 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2413:7 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:737:9 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2413:7 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:76:7 in 'codegen'
from src/compiler/crystal/codegen/codegen.cr:72:5 in 'codegen:debug:frame_pointers:single_module'
from src/compiler/crystal/progress_tracker.cr:22:7 in 'codegen'
from src/compiler/crystal/compiler.cr:204:16 in 'compile:combine_rpath'
from src/compiler/crystal/compiler.cr:197:56 in 'compile:combine_rpath'
from src/compiler/crystal/command.cr:360:3 in 'compile'
from src/compiler/crystal/command.cr:239:5 in 'run_command'
from src/compiler/crystal/command.cr:112:7 in 'run'
from src/compiler/crystal/command.cr:55:5 in 'run'
from src/compiler/crystal/command.cr:54:3 in 'run'
from src/compiler/crystal.cr:11:1 in '__crystal_main'
from src/crystal/main.cr:129:5 in 'main_user_code'
from src/crystal/main.cr:115:7 in 'main'
from src/crystal/main.cr:141:3 in 'main'
Duplicate of #9124?
Duplicate of #9124