Unknowm error: while requiring "prelude" (Exception)

I this the right exception for the following code:

def main(n : Int32, text : String)
end
 
main

Exception:

while requiring "prelude" (Exception)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from main
  from __libc_start_main
  from _start
  from ???
Caused by: while requiring "crystal/main" (Exception)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from main
  from __libc_start_main
  from _start
  from ???
Caused by: BUG: called Int32.restriction_of?(Int32) (Exception)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from main
  from __libc_start_main
  from _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

Hi!

There’s a bug where you can’t define a top-level method named “main”: https://github.com/crystal-lang/crystal/issues/4761

Please use another name until that’s fixed.

Also, you can put “main” inside the top-level code, there’s no need for a “main” method like in other languages.

3 Likes

Thank you!