Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Aug 19, 2024
1 parent 604a8a0 commit f589348
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions tests/generics/t23854.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# issue #23854
# issue #23854, not entirely fixed

import std/bitops

Expand All @@ -23,6 +23,10 @@ type

FF*[Name: static Algebra] = Fp[Name] or Fr[Name]

template getBigInt*[Name: static Algebra](T: type FF[Name]): untyped =
## Get the underlying BigInt type.
typeof(default(T).residue_form)

type
EC_ShortW_Aff*[F] = object
## Elliptic curve point for a curve in Short Weierstrass form
Expand All @@ -35,10 +39,6 @@ type FieldKind* = enum
kBaseField
kScalarField

template getBigInt*[Name: static Algebra](T: type FF[Name]): untyped =
## Get the underlying BigInt type.
BigInt[123]

func bits*[Name: static Algebra](T: type FF[Name]): static int =
T.getBigInt().bits

Expand All @@ -64,7 +64,7 @@ template getBits[bits: static int](x: ptr UncheckedArray[BigInt[bits]]): int = b
proc main() =
let ctx = ECFFT_Descriptor[EC_ShortW_Aff[Fp[BLS12_381]]].new()
when false: echo getBits(ctx.rootsOfUnity2) # doesn't work yet?
doAssert ctx.rootsOfUnity1[0].limbs.len == wordsRequired(123)
doAssert ctx.rootsOfUnity2[0].limbs.len == wordsRequired(123)
doAssert ctx.rootsOfUnity1[0].limbs.len == wordsRequired(255)
doAssert ctx.rootsOfUnity2[0].limbs.len == wordsRequired(255)

main()
8 changes: 4 additions & 4 deletions tests/generics/t23855.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# issue #23855
# issue #23855, not entirely fixed

import std/bitops

Expand All @@ -25,7 +25,7 @@ type

template getBigInt*[Name: static Algebra](T: type FF[Name]): untyped =
## Get the underlying BigInt type.
BigInt[123]
typeof(default(T).residue_form)

type
EC_ShortW_Aff*[F] = object
Expand Down Expand Up @@ -55,7 +55,7 @@ template getBits[bits: static int](x: ptr UncheckedArray[BigInt[bits]]): int = b

proc main() =
let ctx = ECFFT_Descriptor[EC_ShortW_Aff[Fp[BLS12_381]]].new()
when false: echo getBits(ctx.rootsOfUnity2) # doesn't work yet?
doAssert ctx.rootsOfUnity[0].limbs.len == wordsRequired(123)
when false: echo getBits(ctx.rootsOfUnity) # doesn't work yet?
doAssert ctx.rootsOfUnity[0].limbs.len == wordsRequired(255)

main()

0 comments on commit f589348

Please sign in to comment.