status-im/nim-stew

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

Closed this issue · 1 comments

jangko commented

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

have been reported in nim-lang/Nim#22216