diff options
author | Saem Ghani <saemghani+github@gmail.com> | 2021-03-24 03:55:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 11:55:58 +0100 |
commit | 7366a3da37605b230823dd4b6db07abb70dbd40b (patch) | |
tree | 68985e28e41d223496195f9d53e8a50179a0ed84 | |
parent | 1590d145757416788e99023ab50c5afae6f8ea36 (diff) | |
download | Nim-7366a3da37605b230823dd4b6db07abb70dbd40b.tar.gz |
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.
-rw-r--r-- | compiler/isolation_check.nim | 3 | ||||
-rw-r--r-- | compiler/reorder.nim | 1 | ||||
-rw-r--r-- | compiler/semgnrc.nim | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/compiler/isolation_check.nim b/compiler/isolation_check.nim index 9c8ca58b4..43db5d59b 100644 --- a/compiler/isolation_check.nim +++ b/compiler/isolation_check.nim @@ -85,6 +85,9 @@ proc checkIsolate*(n: PNode): bool = of nkCharLit..nkNilLit: result = true of nkCallKinds: + # XXX: as long as we don't update the analysis while examining arguments + # we can do an early check of the return type, otherwise this is a + # bug and needs to be moved below if n[0].typ.flags * {tfGcSafe, tfNoSideEffect} == {}: return false for i in 1..<n.len: diff --git a/compiler/reorder.nim b/compiler/reorder.nim index d2b89f392..4ffe4ccf8 100644 --- a/compiler/reorder.nim +++ b/compiler/reorder.nim @@ -107,6 +107,7 @@ proc computeDeps(cache: IdentCache; n: PNode, declares, uses: var IntSet; topLev for i in 0..<n.safeLen: deps(n[i]) of nkMixinStmt, nkBindStmt: discard else: + # XXX: for callables, this technically adds the return type dep before args for i in 0..<n.safeLen: deps(n[i]) proc hasIncludes(n:PNode): bool = diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index dfbb022c8..615413fc6 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -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) |