Skip to content

[BUG] Compiling function failed with type error in range pattern case #41

@rickyvetter

Description

@rickyvetter

Describe the bug
I've been able to reproduce the following error:

Uncaught (in promise) CompileError: WebAssembly.instantiateStreaming(): Compiling function #366 failed: type error in fallthru[0] (expected (ref i31), got (ref eq)) @+118976

With a minimal set of code that looks like:

let fn_const r _ = r

let int_of_hex c =
  match c with
  | '0' .. '9' -> 1
  | 'a' -> 0
  | _ -> failwith "nope"
;;

let int64_of_hex c = Stdlib.Int64.of_int (int_of_hex c)
let combine = fn_const (int64_of_hex 'c') (int64_of_hex 'c')
let () = print_endline (Stdlib.Int64.to_string combine)

Expected behavior
I'd expect this code to compile and run (with errors)

Versions
This fails when passing --opt 3. If you don't pass an opt flag, the code and wasm both compile. We use a slightly different build of wasm_of_ocaml, so for clarity --opt 3 passes -O3 --skip-pass=inlining-optimizing --traps-never-happen to binaryen

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions