Minor changes and additions to comments

This commit is contained in:
Mattia Giambirtone 2023-01-22 18:02:31 +01:00
parent d1d5c10e49
commit dccaf7dda4
2 changed files with 4 additions and 1 deletions

View File

@ -651,7 +651,7 @@ method infer*(self: Compiler, node: Expression): Type =
method inferOrError*(self: Compiler, node: Expression): Type =
## Attempts to infer the type of
## the given expression and raises an
## error with if it fails
## error if it fails
result = self.infer(node)
if result.isNil():
self.error("expression has no type", node)

View File

@ -1810,6 +1810,9 @@ proc varDecl(self: BytecodeCompiler, node: VarDecl) =
# If this doesn't fail, then we're good
typ = expected
else:
# Let the compiler infer the type (this
# is the default behavior already, but
# some users may prefer to be explicit!)
typ = self.infer(node.value)
self.expression(node.value)
self.emitByte(AddVar, node.token.line)