Fix patterns grab recursion
This commit is contained in:
parent
c0cff79313
commit
a0355637d8
|
@ -103,7 +103,7 @@ proc grab*[T](pr: Value): Pattern =
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError, "cannot generate a pattern for unhandled Value type")
|
raise newException(ValueError, "cannot generate a pattern for unhandled Value type")
|
||||||
|
|
||||||
proc grab*[T](val: T): Pattern =
|
proc grab*[T](x: T): Pattern =
|
||||||
## Construct a `Pattern` from value of type `T`.
|
## Construct a `Pattern` from value of type `T`.
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
from std/unittest import check
|
from std/unittest import check
|
||||||
|
@ -111,7 +111,7 @@ proc grab*[T](val: T): Pattern =
|
||||||
$grab(true) == "<lit #t>"
|
$grab(true) == "<lit #t>"
|
||||||
$grab(3.14) == "<lit 3.14>"
|
$grab(3.14) == "<lit 3.14>"
|
||||||
$grab([0, 1, 2, 3]) == "<arr [<lit 0> <lit 1> <lit 2> <lit 3>]>"
|
$grab([0, 1, 2, 3]) == "<arr [<lit 0> <lit 1> <lit 2> <lit 3>]>"
|
||||||
grab(val)
|
grab(x.toPreserves)
|
||||||
|
|
||||||
proc patternOfType(typ: static typedesc; `bind`: static bool): Pattern =
|
proc patternOfType(typ: static typedesc; `bind`: static bool): Pattern =
|
||||||
when typ is ref:
|
when typ is ref:
|
||||||
|
|
Loading…
Reference in New Issue