Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash when using a TypeDeclaration in the wrong spot #14298

Closed
jwoertink opened this issue Feb 15, 2024 · 3 comments
Closed

Compiler crash when using a TypeDeclaration in the wrong spot #14298

jwoertink opened this issue Feb 15, 2024 · 3 comments

Comments

@jwoertink
Copy link
Contributor

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.

@HertzDevil
Copy link
Contributor

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'

@Blacksmoke16
Copy link
Member

Duplicate of #9124?

@straight-shoota straight-shoota closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
@straight-shoota
Copy link
Member

Duplicate of #9124

@straight-shoota straight-shoota marked this as a duplicate of #9124 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants