Open sibarras opened 3 months ago
I think it's working as intended.
You cannot define a variable without var
at all, this is intended
So, it should be more like a feature request?
For me, it's a bug. If implicit declarations are allowed, annotating them should be also allowed.
What happens when you do f2: Foo = 1
?
f2: Foo = 1 is not allowed. But f2 = 1 and var f2: Foo = 1 are ok. The problem is when you want to do implicit initialization, you usually tell the compiler using the type annotation, but you can't annotate a implicit variable declaration. So you can't build a String using a StringLiteral, because str = "hello" will always produce StringLiteral. trying str: String = "hello" will fail. You have two options: str = String("hello") or var str: String = "hello"
Bug description
Recently on Nightly we are allowed to implicitly create a variable, without the
var
keyword. Still we cannot annotate those variables with a type, or create a uninitialized variable.Steps to reproduce
System information