Skip to content

raise_notrace with variant unboxing doesn't work #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mshinwell opened this issue Jun 21, 2021 · 1 comment
Open

raise_notrace with variant unboxing doesn't work #487

mshinwell opened this issue Jun 21, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mshinwell
Copy link

When local exceptions are turned into jumps, unboxing applies. However in this example, the argument of Exit3 doesn't get unboxed.

type 'a ref = { mutable contents : 'a }
external ref : 'a -> 'a ref = "%makemutable"
external ( ! ) : 'a ref -> 'a = "%field0"
external ( := ) : 'a ref -> 'a -> unit = "%setfield0"
external ( < ) : 'a -> 'a -> bool = "%lessthan"
external ( + ) : int -> int -> int = "%addint"
external ( +. ) : float -> float -> float = "%addfloat"
external raise : exn -> 'a = "%raise"
external raise_notrace : exn -> 'a = "%raise_notrace"

exception Exit3 of int option

let f5 x g =
  let r = ref x in
  try
    while !r < 42 do
      if
        try g !r
        with _ -> false
      then begin
        if !r < 4 then raise_notrace (Exit3 (Some (!r + 2)))
        else raise_notrace (Exit3 None)
      end;
      r := !r + 1
    done;
    0
  with (Exit3 x) ->
    match x with
    | None -> 4
    | Some x -> x + 5
@mshinwell mshinwell added the bug Something isn't working label Jun 21, 2021
@lthls
Copy link

lthls commented Jul 2, 2021

This issue can be fixed by combining #316 and #532.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants