diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-07-27 09:36:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 09:36:19 +0200 |
commit | fa0209609d3bedd3466f162aa350d261907851ce (patch) | |
tree | e3868ea46bf5082cb114e6b328a9b6c9e8f84d07 | |
parent | 9cb5ab0108c62bfda30b4f9b52b2957fdd364544 (diff) | |
download | Nim-fa0209609d3bedd3466f162aa350d261907851ce.tar.gz |
fixes #18565 (#18593)
* fixes #18565
-rw-r--r-- | compiler/semstmts.nim | 22 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 4 | ||||
-rw-r--r-- | tests/arc/tkeys_lent.nim | 17 | ||||
-rw-r--r-- | tests/stdlib/tgetfileinfo.nim | 1 | ||||
-rw-r--r-- | tests/stdlib/tos.nim | 1 |
5 files changed, 33 insertions, 12 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index bfce91849..75323a95e 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2260,20 +2260,20 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode = # nkNilLit, nkEmpty}: # dec last for i in 0..<n.len: - var expr = semExpr(c, n[i], flags) - n[i] = expr - if c.matchedConcept != nil and expr.typ != nil and + var x = semExpr(c, n[i], flags) + n[i] = x + if c.matchedConcept != nil and x.typ != nil and (nfFromTemplate notin n.flags or i != last): - case expr.typ.kind + case x.typ.kind of tyBool: - if expr.kind == nkInfix and - expr[0].kind == nkSym and - expr[0].sym.name.s == "==": - if expr[1].typ.isUnresolvedStatic: - inferConceptStaticParam(c, expr[1], expr[2]) + if x.kind == nkInfix and + x[0].kind == nkSym and + x[0].sym.name.s == "==": + if x[1].typ.isUnresolvedStatic: + inferConceptStaticParam(c, x[1], x[2]) continue - elif expr[2].typ.isUnresolvedStatic: - inferConceptStaticParam(c, expr[2], expr[1]) + elif x[2].typ.isUnresolvedStatic: + inferConceptStaticParam(c, x[2], x[1]) continue let verdict = semConstExpr(c, n[i]) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 73ab5e9a3..6bc641bd6 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -625,7 +625,7 @@ proc procTypeRel(c: var TCandidate, f, a: PType): TTypeRelation = return isNone elif a[0] != nil: return isNone - + result = getProcConvMismatch(c.c.config, f, a, result)[1] when useEffectSystem: @@ -2272,6 +2272,8 @@ proc prepareOperand(c: PContext; formal: PType; a: PNode): PNode = else: result = a considerGenSyms(c, result) + if result.kind != nkHiddenDeref and result.typ.kind in {tyVar, tyLent} and c.matchedConcept == nil: + result = newDeref(result) proc prepareOperand(c: PContext; a: PNode): PNode = if a.typ.isNil: diff --git a/tests/arc/tkeys_lent.nim b/tests/arc/tkeys_lent.nim new file mode 100644 index 000000000..2c92350b1 --- /dev/null +++ b/tests/arc/tkeys_lent.nim @@ -0,0 +1,17 @@ +discard """ + output: '''{"string": 2}''' + cmd: "nim c --gc:orc $file" +""" + +import tables + +proc use(x: int) = echo x + +proc main = + var tab = {"string": 1}.toTable + for keyAAA in tab.keys(): + template alias(): untyped = tab[keyAAA] + alias() = 2 + echo tab + +main() diff --git a/tests/stdlib/tgetfileinfo.nim b/tests/stdlib/tgetfileinfo.nim index 19de193e4..099ce1c22 100644 --- a/tests/stdlib/tgetfileinfo.nim +++ b/tests/stdlib/tgetfileinfo.nim @@ -1,5 +1,6 @@ discard """ output: "pcDir\npcFile\npcLinkToDir\npcLinkToFile\n" + joinable: false """ import os, strutils diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim index d598a05b2..fedf2b3e3 100644 --- a/tests/stdlib/tos.nim +++ b/tests/stdlib/tos.nim @@ -22,6 +22,7 @@ __really_obscure_dir_name/test Raises Raises ''' + joinable: false """ # test os path creation, iteration, and deletion |