Unfortunately, the code that gives me this is fairly complex, and my attempts at isolating a test case all have made the error disappear. The code is (with partial definitions):
type
OrdResult* = tuple[iscenario: int, sresult: ScenarioResult]
ResultsIter* = iterator(): OrdResult {.closure.}
proc runner*(features: Features) : ResultsIter =
iterator iresults() : OrdResult {.closure.} =
var i = 0;
for feature in features:
resetContext(ctFeature)
for scenario in feature.scenarios:
if scenario.examples.len == 0:
yield (i, runScenario(scenario))
i += 1
else:
for escenario in exampleScenarios(scenario):
yield (i, runScenario(escenario))
i += 1
return iresults
My first thought was that I wasn't allowed to pass an iterator from a closure (which referenced an object from surrounding closure)... but a simple test of this worked. I though someone with more experience could point out the most probable cause?
EDIT: ok ... I've made the problem go away. It turns out "exampleScenarios" was a default (inline) iterator which however declared a local function (not declared inline) that used values from its scope. When I (manually) inlined that function the error went away. So probably a compiler bug in here but trying to recreate with a sensible test case still didn't work. To find this bug you just have to lure more coders used to writing javascript, and I'm sure it will pop right out. :)