To my surprise, this fails to compile unless Int.class is parenthesized:
x : Int.class? # Error: expecting identifier 'class', not 'class?'
x = Int32
def foo(x : Int.class? = nil) # Error: expecting identifier 'class', not 'class?'
end
I would expect it to be parsed as Int.class | ::Nil instead.
This only goes for the type grammar, .class? should always be a regular method in normal code (which is already the case for Crystal::Type inside the compiler).
To my surprise, this fails to compile unless
Int.class
is parenthesized:I would expect it to be parsed as
Int.class | ::Nil
instead.This only goes for the type grammar,
.class?
should always be a regular method in normal code (which is already the case forCrystal::Type
inside the compiler).