avoid typed return in generic template (#739)

This commit is contained in:
Jacek Sieka 2024-10-02 09:33:22 +02:00 committed by GitHub
parent 086ac68c86
commit 70b7519f02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -55,8 +55,10 @@ type
## See also: ## See also:
## * https://github.com/status-im/nimbus-eth1/issues/35 ## * https://github.com/status-im/nimbus-eth1/issues/35
template to*[N: static int](v: array[N, byte], T: type FixedBytes[N]): T = template to*[N: static int](v: array[N, byte], T: type FixedBytes[N]): untyped =
T(v) # using a typed return here runs into an assortment of generics bugs when the
# compiler fails to instantiate N
FixedBytes[sizeof(v)](v)
template data*[N: static int](v: FixedBytes[N]): array[N, byte] = template data*[N: static int](v: FixedBytes[N]): array[N, byte] =
distinctBase(v) distinctBase(v)