-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot instantiate generic object with cast to generic type in template #22645
Comments
!nim c type
Opt[T] = object
FutureBase* = ref object of RootObj
Future*[T] = ref object of FutureBase
internalValue*: T
template err[T](E: type Opt[T]): E = E()
proc works(): Future[Opt[int]] {.stackTrace: off, gcsafe, raises: [].} =
var chronosInternalRetFuture: FutureBase
template result(): untyped {.used.} =
Future[Opt[int]](chronosInternalRetFuture).internalValue
result = err(type(result))
proc breaks(): Future[Opt[int]] {.stackTrace: off, gcsafe, raises: [].} =
var chronosInternalRetFuture: FutureBase
template result(): untyped {.used.} =
cast[Future[Opt[int]]](chronosInternalRetFuture).internalValue
result = err(type(result)) |
@juancarlospaco (collaborator) devel 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) stable 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) 2.0.0 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) 1.6.0 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) 1.4.0 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) 1.2.0 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) 1.0.0 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) 0.20.2 👎 FAILOutput
Stats
IRCompiled filesize0 bytes (0 bytes)
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Opt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("FutureBase")
),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("RootObj")
),
newEmptyNode()
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("Future")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
nnkOfInherit.newTree(
newIdentNode("FutureBase")
),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("internalValue")
),
newIdentNode("T"),
newEmptyNode()
)
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("err"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("E"),
nnkIdentDefs.newTree(
newIdentNode("E"),
nnkCommand.newTree(
newIdentNode("type"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("T")
)
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
newIdentNode("E")
)
)
),
nnkProcDef.newTree(
newIdentNode("works"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("breaks"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
)
),
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("stackTrace"),
newIdentNode("off")
),
newIdentNode("gcsafe"),
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
)
)
),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("chronosInternalRetFuture"),
newIdentNode("FutureBase"),
newEmptyNode()
)
),
nnkTemplateDef.newTree(
newIdentNode("result"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("untyped")
),
nnkPragma.newTree(
newIdentNode("used")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkDotExpr.newTree(
nnkCast.newTree(
nnkBracketExpr.newTree(
newIdentNode("Future"),
nnkBracketExpr.newTree(
newIdentNode("Opt"),
newIdentNode("int")
)
),
newIdentNode("chronosInternalRetFuture")
),
newIdentNode("internalValue")
)
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkCall.newTree(
newIdentNode("err"),
nnkCall.newTree(
newIdentNode("type"),
newIdentNode("result")
)
)
)
)
)
) Stats
🤖 Bug found in |
Simplified (maybe type
Opt[T] = object
Future[T] = object
template err[T](E: typedesc[Future[Opt[T]]]): E = E()
var foo: Future[Opt[int]]
template bar(): untyped =
cast[Future[Opt[int]]](foo)
discard err type(bar) Typed AST difference between cast and conversion: type
Opt[T] = object
Future[T] = object
proc err[T](E: typedesc[Future[Opt[T]]]): E = E() # avoid resem, works around bug
var foo: Future[Opt[int]]
template barCast(): untyped =
cast[Future[Opt[int]]](foo)
template barConv(): untyped =
Future[Opt[int]](foo)
import macros
macro typedTree(x: typed) =
result = x
echo x.treeRepr
typedTree:
discard err type(barCast)
discard err type(barConv)
|
Seems to work now probably because of #23983 |
metagn
added a commit
to metagn/Nim
that referenced
this issue
Aug 29, 2024
closes nim-lang#1969, closes nim-lang#7737, closes nim-lang#11838, closes nim-lang#12283, closes nim-lang#14053, closes nim-lang#16118, closes nim-lang#19670, closes nim-lang#22645
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Bonus points for such an excellent compiler error message ;)
Nim Version
1.6.14
Current Output
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: