feat: allow variable declarations without explicit initializers
In the compiler, when parsing a variable declaration, the `=` token is now optional. If present, the initializer expression is compiled as before. If absent, the variable is implicitly initialized to `null` via a call to `null(compiler, false)`. This change removes the previous `TODO` comment and the unconditional `consume` of `TOKEN_EQ`. Two new test files verify the behavior for both global and local variables without initializers, asserting that reading such a variable yields `null`.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
var a
|
||||
IO.write(a) // expect: null
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
var a
|
||||
IO.write(a) // expect: null
|
||||
}
|
||||
Reference in New Issue
Block a user