Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed May 20, 2021
1 parent ab1d136 commit e425f0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule;
let a0 = a
while a != nil:
if i == 1:
# this is needed, see D20210519T200936 and D20210519T201000
if c.getCurrOwner.kind != skModule and c.getCurrOwner == a0.owner and a.owner != a0.owner:
break
if a.kind != skModule:
Expand Down
18 changes: 14 additions & 4 deletions tests/generics/t13747.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
discard """
joinable: false
matrix: "-d:t13747_case1 -d:t13747_case2 -d:t13747_case3 -d:t13747_case4 -d:t13747_case5 -d:t13747_case6 -d:t13747_case7 -d:t13747_case8"
# this allows testing each one individually; each of those (except t13747_case1) were failing
matrix: "-d:t13747_case1 -d:t13747_case2 -d:t13747_case3 -d:t13747_case4 -d:t13747_case5 -d:t13747_case6 -d:t13747_case7 -d:t13747_case8 -d:t13747_case9"
# this allows testing each one individually; each of those (except t13747_case1, t13747_case7, t13747_case8) were failing
"""

# bug #13747 generic sandwich non-module scope symbols were ignored
Expand Down Expand Up @@ -128,15 +128,25 @@ when defined(t13747_case6): # bug #17965
doAssert @[a] == @[b] # was failing

when defined(t13747_case7):
# makes sure this keeps working
# D20210519T201000:here makes sure this keeps working
proc cmp(a: string) = discard
template genericTests() =
let fn = cmp[int]
genericTests()

when defined t13747_case8: # bug #2752
# D20210519T200936:here makes sure this keeps working; this is a minimized version of bug #2752;
# the non-minimized is in tests/generics/tgenerics_issues.nim (formerly tests/generics/tdont_use_inner_scope.nim)
proc myFilter[T](a: T) =
proc aNameWhichWillConflict(z: int) = discard
let foo = aNameWhichWillConflict # semstmts.nim:500:12 in: semVarOrLet def.kind: nkClosedSymChoice;
block:
proc aNameWhichWillConflict(x: string) = discard
myFilter(1)

# tests that need an stdlib import come after

when defined(t13747_case8): # bug #13970
when defined(t13747_case9): # bug #13970
# (also reported in https://github.com/nim-lang/Nim/issues/13747#issuecomment-612905795)
import algorithm
block:
Expand Down

0 comments on commit e425f0c

Please sign in to comment.