codex-storage / questionable

Elegant optional types for Nim
Other
116 stars 5 forks source link

Fix: `without` should work when `$` has side effects #58

Closed markspanbroek closed 6 months ago

markspanbroek commented 6 months ago

When a type has a $ proc that might produce side effects, then a without statement that tries to bind this type fails with a compilation error:

results.nim(373, 6) Error: 'raiseResultDefect' can have side effects

This fix avoids invoking the raiseResultDefect func by using .unsafeError instead of .error . It's ok to use unsafeError in bindFailed, because we've already checked that the result contains an error.