fixes #13646
This commit is contained in:
parent
3a6b470412
commit
a102eb5ef6
3 changed files with 34 additions and 6 deletions
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
discard """
|
||||
output: '''[1, 0, 0, 0, 0, 0, 0, 0]
|
||||
CTBool[Ct[system.uint32]]'''
|
||||
"""
|
||||
|
||||
block tconstraints:
|
||||
proc myGenericProc[T: object|tuple|int|ptr|ref|distinct](x: T): string =
|
||||
|
|
@ -37,13 +40,29 @@ block tfieldaccessor:
|
|||
block tprocbothmeta:
|
||||
proc myFun[A](x: A): auto =
|
||||
result = float(x+10)
|
||||
|
||||
|
||||
proc myMap[T,S](sIn: seq[T], f: proc (q: T): S): seq[S] =
|
||||
result = newSeq[S](sIn.len)
|
||||
for i in 0..<sIn.len:
|
||||
result[i] = f(sIn[i])
|
||||
|
||||
|
||||
assert myMap(@[1,2,3], myFun) == @[11.0, 12.0, 13.0]
|
||||
|
||||
|
||||
# https://github.com/nim-lang/Nim/issues/13646
|
||||
|
||||
type
|
||||
BaseUint* = SomeUnsignedInt or byte
|
||||
Ct*[T] = distinct T
|
||||
## Constant-Time wrapper
|
||||
## Only constant-time operations in particular the ternary operator equivalent
|
||||
## condition: if true: a else: b
|
||||
## are allowed
|
||||
|
||||
CTBool*[T] = distinct range[T(0)..T(1)]
|
||||
## Constant-Time boolean wrapper
|
||||
|
||||
var x: array[8, CTBool[Ct[uint32]]]
|
||||
x[0] = (CTBool[Ct[uint32]])(1)
|
||||
echo x.repr, " ", typeof(x[0])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue