status-im / nim-stew

stew is collection of utilities, std library extensions and budding libraries that are frequently used at Status, but are too small to deserve their own git repository.
133 stars 18 forks source link

withAssertOk introduce compile time regression of Results[T, E] #202

Closed jangko closed 1 year ago

jangko commented 1 year ago

PR #198 change assertOk to withAssertOk, and it make compiletime regression of Results.

import 
  ../stew/results

func bug(): Result[uint16, string] =
  ok(1234)

const
  x = bug()
  y = x.value()

echo y

Current output: 0 Expected output: 1234

If we change const to let, it will works as expected. It maybe a Nim bug, but I think we should make it works again while wait for nim compiler get fixed.

See also status-im/nimbus-eth1#1617

ping @etan-status

jangko commented 1 year ago

have been reported in nim-lang/Nim#22216