Temporary fix for not closing over function arguments
This commit is contained in:
parent
13cc641e7b
commit
39d1eab234
|
@ -450,9 +450,13 @@ proc detectClosureVariable(self: Compiler, name: var Name, depth: int = self.sco
|
|||
if self.closedOver.len() >= 16777216:
|
||||
self.error("too many consecutive closed-over variables (max is 16777215)")
|
||||
name.isClosedOver = true
|
||||
self.chunk.code[name.codePos] = StoreClosure.uint8()
|
||||
for i, b in self.closedOver.high().toTriple():
|
||||
self.chunk.code[name.codePos + i + 1] = b
|
||||
if not name.isFunctionArgument:
|
||||
# We handle closed-over function arguments later
|
||||
self.chunk.code[name.codePos] = StoreClosure.uint8()
|
||||
for i, b in self.closedOver.high().toTriple():
|
||||
self.chunk.code[name.codePos + i + 1] = b
|
||||
else:
|
||||
self.error("it is currently not possible to close over function arguments")
|
||||
|
||||
|
||||
proc compareTypes(self: Compiler, a, b: Type): bool =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn makeClosure(n: int): fn: int {
|
||||
var n = n;
|
||||
# let n = n; # Workaround
|
||||
fn inner: int {
|
||||
return n;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue