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
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
Most helpful comment
should be a better error message