Open BrucePerens opened 4 years ago
Thank you for this report.
When pasting crystal code, if you put "crystal" next to the three fist backquotes you'll get syntax highlighting, which helps understanding the code faster. I've been doing that for you in the last bug reports, just letting you know.
I think this is pretty hard to fix, so my idea of a solution would be to disallow typeof
inside is_a?
.
In this particular example, I can work out another way to get a class object for the contents of an array, so that would be OK. So, "Error: typeof() within type restriction doesn't work yet"?
I would also probably try and avoid having an AnyType
. At that point you kinda lose the benefits of static typing...
More like "Can't use typeof
inside is_a?
". I wouldn't say "yet" because I think there's no way to fix it without a major rewrite of the compiler.
OK. Please document what operators don't work within is_a? as part of the fix.
The AnyType in this case gives a name to a type union that the compiler would otherwise call Value+. This is a fragment of a computer language with some dyadic operators that can compare the Crystal types Bool
, String
, or Int64|Float64
. So, those operators do type checking in its compile pass.
This code fragment triggers the internal compiler BUG check for "has no type" at semantic/bindings.cr:13
I get this stack dump:
Version: