Crystal: Unable to create a Flags module

Created on 23 Dec 2019  路  2Comments  路  Source: crystal-lang/crystal

Code to reproduce:

class Flags::Foo
end

Flags::Foo.new

Error output:

cast from Crystal::AnnotationType to Crystal::ModuleType+ failed, at /private/tmp/crystal-20191218-6722-1jszepb/crystal-0.32.1/src/compiler/crystal/semantic/top_level_visitor.cr:1128:6:1128 (TypeCastError)
  from Crystal::TopLevelVisitor#lookup_type_def_name<Crystal::Path>:Tuple(Crystal::ModuleType+, String)
  from Crystal::TopLevelVisitor#visit<Crystal::ClassDef>:Bool
  from Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::TopLevelVisitor>:Nil
  from Crystal::TopLevelVisitor#visit<Crystal::Expressions>:Bool
  from Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::TopLevelVisitor>:Nil
  from Crystal::Program#top_level_semantic<Crystal::ASTNode+>:Tuple(Crystal::ASTNode+, Crystal::TypeDeclarationProcessor)
  from Crystal::Program#semantic<Crystal::ASTNode+, Bool>:Crystal::ASTNode+
  from Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result
  from Crystal::Command#run_command<Bool>:Nil
  from Crystal::Command#run:(Bool | Crystal::Compiler::Result | Nil)
  from main
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

crystal --version output:

Crystal 0.32.1 (2019-12-18)

LLVM: 9.0.0
Default target: x86_64-apple-macosx
help-wanted bug compiler

Most helpful comment

should be a better error message

All 2 comments

I found that Flags is an annotation, and if I make Flags the class instead of the module I get an error that says as such.

should be a better error message

Was this page helpful?
0 / 5 - 0 ratings