Fix regression with runnableExamples in generic expr
The examples should not enter the generic analysis at all.
The regression was introduced in 4cf704bb as a fix for #8694.
Fixes #9130
Fixes #8694
This commit is contained in:
parent
5676e032bd
commit
6d4503325c
3 changed files with 69 additions and 5 deletions
31
tests/generics/t8694.nim
Normal file
31
tests/generics/t8694.nim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
discard """
|
||||
output: '''
|
||||
true
|
||||
true
|
||||
true
|
||||
'''
|
||||
"""
|
||||
|
||||
when true:
|
||||
# Error: undeclared identifier: '|'
|
||||
proc bar[T](t:T): bool =
|
||||
runnableExamples:
|
||||
type Foo = int | float
|
||||
true
|
||||
echo bar(0)
|
||||
|
||||
when true:
|
||||
# ok
|
||||
proc bar(t:int): bool =
|
||||
runnableExamples:
|
||||
type Foo = int | float
|
||||
true
|
||||
echo bar(0)
|
||||
|
||||
when true:
|
||||
# Error: undeclared identifier: '|'
|
||||
proc bar(t:typedesc): bool =
|
||||
runnableExamples:
|
||||
type Foo = int | float
|
||||
true
|
||||
echo bar(int)
|
||||
33
tests/generics/t9130.nim
Normal file
33
tests/generics/t9130.nim
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
when true:
|
||||
# stack overflow
|
||||
template baz1*(iter: untyped): untyped =
|
||||
runnableExamples:
|
||||
import sugar
|
||||
proc fun(a: proc(x:int): int) = discard
|
||||
baz1(fun(x:int => x))
|
||||
discard
|
||||
|
||||
proc foo1[A](ts: A) =
|
||||
baz1(ts)
|
||||
|
||||
when true:
|
||||
# ok
|
||||
template baz2*(iter: untyped): untyped =
|
||||
runnableExamples:
|
||||
import sugar
|
||||
proc fun(a: proc(x:int): int) = discard
|
||||
baz2(fun(x:int => x))
|
||||
discard
|
||||
|
||||
proc foo2(ts: int) =
|
||||
baz2(ts)
|
||||
|
||||
when true:
|
||||
# stack overflow
|
||||
template baz3*(iter: untyped): untyped =
|
||||
runnableExamples:
|
||||
baz3(fun(x:int => x))
|
||||
discard
|
||||
|
||||
proc foo3[A](ts: A) =
|
||||
baz3(ts)
|
||||
Loading…
Add table
Add a link
Reference in a new issue