I found that, in the code below, `myEncodeQuery` works well while 
`myAsyncEncodeQuery` isn't even compiled.
    
    
    import uri, asyncdispatch
    
    proc myAsyncEncodeQuery(query: openArray[(string, string)]) {.async.} =
      echo(encodeQuery(query))
    
    proc myEncodeQuery(query: openArray[(string, string)]) =
      echo(encodeQuery(query))
    
    echo(encodeQuery({"foo": "bar", "baz": "qux"}))
    
    myEncodeQuery({"foo": "bar", "baz": "qux"})
    
    # commenting the line below will eliminate the compile error.
    waitFor myAsyncEncodeQuery({"foo": "bar", "baz": "qux"})
    
    
    Run

I got a compilation error something like:
    
    
    Error: 'query' is of type <openarray[tuple of (string, string)]> which 
cannot be captured as it would violate memory safety, declared here: 
D:\...\test.nim(3, 25)
    
    
    Run

What kind of memory safety violation it is causing, and is there any way to 
avoid the error?

Reply via email to