fix deprecated example (#18721)

This commit is contained in:
flywind
2021-08-21 14:22:00 +08:00
committed by GitHub
parent f0c6593412
commit 5b26f2bd81
2 changed files with 27 additions and 11 deletions

View File

@@ -871,11 +871,20 @@ static:
scope:
macro testRecCase(ast: untyped): untyped =
ast.peelOff({nnkStmtList, nnkTypeSection})[2].matchAst:
of nnkObjectTy(
nnkPragma(
ident"inheritable"
ast.peelOff({nnkStmtList, nnkTypeSection}).matchAst:
of nnkTypeDef(
nnkPragmaExpr(
ident"Obj",
nnkPragma(ident"inheritable")
),
nnkGenericParams(
nnkIdentDefs(
ident"T",
nnkEmpty(),
nnkEmpty())
),
nnkObjectTy(
nnkEmpty(),
nnkEmpty(),
nnkRecList( # list of object parameters
nnkIdentDefs(
@@ -914,6 +923,7 @@ static:
ident"T"
),
nnkEmpty()
)
)
)
)
@@ -922,10 +932,8 @@ static:
):
echo "ok"
testRecCase:
type Obj[T] = object {.inheritable.}
type Obj[T] {.inheritable.} = object
name: string
case isFat: bool
of true: