potential fix for semgeneric formal params (#17494)

marked locations where analysis of return formal param is done prior to
args. This might fix some subtle bugs.
This commit is contained in:
Saem Ghani 2021-03-24 03:55:58 -07:00 • committed by GitHub
commit 7366a3da37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -452,8 +452,6 @@ proc semGenericStmt(c: PContext, n: PNode,
discard
of nkFormalParams:
checkMinSonsLen(n, 1, c.config)
if n[0].kind != nkEmpty:
n[0] = semGenericStmt(c, n[0], flags+{withinTypeDesc}, ctx)
for i in 1..<n.len:
var a = n[i]
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
@ -462,6 +460,10 @@ proc semGenericStmt(c: PContext, n: PNode,
a[^1] = semGenericStmt(c, a[^1], flags, ctx)
for j in 0..<a.len-2:
addTempDecl(c, getIdentNode(c, a[j]), skParam)
# XXX: last change was moving this down here, search for "1.." to keep
# going from this file onward
if n[0].kind != nkEmpty:
n[0] = semGenericStmt(c, n[0], flags+{withinTypeDesc}, ctx)
of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef,
nkFuncDef, nkIteratorDef, nkLambdaKinds:
checkSonsLen(n, bodyPos + 1, c.config)