MicroHs icon indicating copy to clipboard operation
MicroHs copied to clipboard

primRnfNoErr can't ignore errors passed to primitives

Open jmaessen opened this issue 2 years ago • 1 comments

I was fiddling with this as primRnfNoErr is a form of cheap-and-cheerful speculation (error-avoiding but not bottom-avoiding eagerness). But it was fairly obvious from reading eval.c that this was going to break:

module Example(main) where
import Prelude
import Primitives

main :: IO ()
main = do
  putStrLn "primRnfNoErr is kind of broken"
  return $! primRnfNoErr ((error "foo") + (3 :: Int))
  putStrLn "Success!"

And indeed:

% bin/mhs -r Example
primRnfNoErr is kind of broken
ERR: evalint, bad tag 2

Brainstorming a bit about how this might be solved cleanly. It'd be nice to be able to fix this without having to add checks at all the calls to evali etc.

jmaessen avatar Jan 16 '24 02:01 jmaessen

Yeah, I know it's kinda broken. It's only(?) used for cprint, so it's not too bad.

If you can figure out a cheap way to unbreak it, that would be great.

augustss avatar Jan 16 '24 06:01 augustss