fix #15916 (#15917) [backport]

* fix #15916

* add testcase for #15916

* add comments
This commit is contained in:
flywind 2020-11-12 16:31:35 +08:00 • committed by GitHub
commit 402df0b061
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View file

@ -592,8 +592,10 @@ proc getRoutineBody(n: PNode): PNode =
(0 or more) doc comments and runnableExamples.
]##
result = n[bodyPos]
if result.kind == nkAsgn and n.len > bodyPos+1 and n[bodyPos+1].kind == nkSym:
doAssert result[0].kind == nkSym
# This won't be transformed: result.id = 10. Namely result[0].kind != nkSym.
if result.kind == nkAsgn and result[0].kind == nkSym and
n.len > bodyPos+1 and n[bodyPos+1].kind == nkSym:
doAssert result.len == 2
result = result[1]