Minor changes and additions to comments
This commit is contained in:
parent
d1d5c10e49
commit
dccaf7dda4
|
@ -651,7 +651,7 @@ method infer*(self: Compiler, node: Expression): Type =
|
||||||
method inferOrError*(self: Compiler, node: Expression): Type =
|
method inferOrError*(self: Compiler, node: Expression): Type =
|
||||||
## Attempts to infer the type of
|
## Attempts to infer the type of
|
||||||
## the given expression and raises an
|
## the given expression and raises an
|
||||||
## error with if it fails
|
## error if it fails
|
||||||
result = self.infer(node)
|
result = self.infer(node)
|
||||||
if result.isNil():
|
if result.isNil():
|
||||||
self.error("expression has no type", node)
|
self.error("expression has no type", node)
|
||||||
|
|
|
@ -1810,6 +1810,9 @@ proc varDecl(self: BytecodeCompiler, node: VarDecl) =
|
||||||
# If this doesn't fail, then we're good
|
# If this doesn't fail, then we're good
|
||||||
typ = expected
|
typ = expected
|
||||||
else:
|
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)
|
typ = self.infer(node.value)
|
||||||
self.expression(node.value)
|
self.expression(node.value)
|
||||||
self.emitByte(AddVar, node.token.line)
|
self.emitByte(AddVar, node.token.line)
|
||||||
|
|
Loading…
Reference in New Issue