fix deprecated example (#18721)
This commit is contained in:
parent
f0c6593412
commit
5b26f2bd81
2 changed files with 27 additions and 11 deletions
|
|
@ -1082,7 +1082,7 @@ its entirety to see some of the complexities.
|
||||||
Concrete syntax:
|
Concrete syntax:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
type Obj[T] = object {.inheritable.}
|
type Obj[T] {.inheritable.} = object
|
||||||
name: string
|
name: string
|
||||||
case isFat: bool
|
case isFat: bool
|
||||||
of true:
|
of true:
|
||||||
|
|
@ -1094,10 +1094,18 @@ AST:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
# ...
|
# ...
|
||||||
nnkObjectTy(
|
nnkPragmaExpr(
|
||||||
nnkPragma(
|
nnkIdent("Obj"),
|
||||||
nnkIdent("inheritable")
|
nnkPragma(nnkIdent("inheritable"))
|
||||||
),
|
),
|
||||||
|
nnkGenericParams(
|
||||||
|
nnkIdentDefs(
|
||||||
|
nnkIdent("T"),
|
||||||
|
nnkEmpty(),
|
||||||
|
nnkEmpty())
|
||||||
|
),
|
||||||
|
nnkObjectTy(
|
||||||
|
nnkEmpty(),
|
||||||
nnkEmpty(),
|
nnkEmpty(),
|
||||||
nnkRecList( # list of object parameters
|
nnkRecList( # list of object parameters
|
||||||
nnkIdentDefs(
|
nnkIdentDefs(
|
||||||
|
|
|
||||||
|
|
@ -871,11 +871,20 @@ static:
|
||||||
|
|
||||||
scope:
|
scope:
|
||||||
macro testRecCase(ast: untyped): untyped =
|
macro testRecCase(ast: untyped): untyped =
|
||||||
ast.peelOff({nnkStmtList, nnkTypeSection})[2].matchAst:
|
ast.peelOff({nnkStmtList, nnkTypeSection}).matchAst:
|
||||||
of nnkObjectTy(
|
of nnkTypeDef(
|
||||||
nnkPragma(
|
nnkPragmaExpr(
|
||||||
ident"inheritable"
|
ident"Obj",
|
||||||
|
nnkPragma(ident"inheritable")
|
||||||
),
|
),
|
||||||
|
nnkGenericParams(
|
||||||
|
nnkIdentDefs(
|
||||||
|
ident"T",
|
||||||
|
nnkEmpty(),
|
||||||
|
nnkEmpty())
|
||||||
|
),
|
||||||
|
nnkObjectTy(
|
||||||
|
nnkEmpty(),
|
||||||
nnkEmpty(),
|
nnkEmpty(),
|
||||||
nnkRecList( # list of object parameters
|
nnkRecList( # list of object parameters
|
||||||
nnkIdentDefs(
|
nnkIdentDefs(
|
||||||
|
|
@ -919,13 +928,12 @@ static:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
):
|
):
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
testRecCase:
|
testRecCase:
|
||||||
type Obj[T] = object {.inheritable.}
|
type Obj[T] {.inheritable.} = object
|
||||||
name: string
|
name: string
|
||||||
case isFat: bool
|
case isFat: bool
|
||||||
of true:
|
of true:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue