Skip to content

Invalid expected type, but got: Raising(Future[void], E) on macro returning type (regression from 1.6) #23432

@arnetheduck

Description

@arnetheduck

Description

import std/[sequtils, macros]

type
  Future[T] = object
  InternalRaisesFuture[T, E] = object

macro Raising*[T](F: typedesc[Future[T]], E: varargs[typedesc]): untyped =
  ## Given a Future type instance, return a type storing `{.raises.}`
  ## information
  ##
  ## Note; this type may change in the future
  E.expectKind(nnkBracket)

  let raises = nnkTupleConstr.newTree(E.mapIt(it))
  nnkBracketExpr.newTree(
    ident "InternalRaisesFuture",
    nnkDotExpr.newTree(F, ident"T"),
    raises
  )

type X[E] = Future[void].Raising(E)

proc f(x: X) = discard


var v: Future[void].Raising([ValueError])
f(v)

Nim Version

works in 1.6, broken in 2.0, devel

Current Output

testit.nim(21, 25) Error: expected type, but got: Raising(Future[void], E)

Expected Output

No response

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions