On the C backend it outputs: > Error: 'arr' is of type <openArray[string]> which cannot be captured as it > would violate memory safety ... using '-d:nimNoLentIterators' helps in some > cases
instead of an internal compiler error. However allowing it in the JS backend may cause it to be inconsistent with other backends. Anyway I think you can change it to: proc foo(arr: openArray[string]): proc = var s = @arr result = proc = for i in s: echo i const arr = @["qwe",] discard foo(arr) Run