Skip to content

Assertion at runtime with await and json.to() #7985

@ghost

Description

Code to reproduce:

import json, asyncdispatch

proc getData(): Future[JsonNode] {.async.} = 
  result = %*{"value": 1}

type 
  MyData = object
    value: BiggestInt

proc main() {.async.} = 
  let data = to(await(getData()), MyData)
  echo data

waitFor(main())

It works if you change let data = to(await getData(), MyData) to

let raw = await(getData())
let data = to(raw, MyData)

It also works with Nim 0.18.0 (that's why I call it a regression), and I think that it started happening after last PRs related to async.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AsyncEverything related to Nim's asyncRegression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions