Skip to content

Commit

Permalink
Fix a bug where types weren't specialized in top level lets
Browse files Browse the repository at this point in the history
  • Loading branch information
Alasdair committed Oct 4, 2023
1 parent 6ef3988 commit e8a0373
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/jib_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ let ctype_def_map_ctyp f = function
(* Map over each ctyp in a cdef using map_instr_ctyp *)
let cdef_map_ctyp f = function
| CDEF_register (id, ctyp, instrs) -> CDEF_register (id, f ctyp, List.map (map_instr_ctyp f) instrs)
| CDEF_let (n, bindings, instrs) -> CDEF_let (n, bindings, List.map (map_instr_ctyp f) instrs)
| CDEF_let (n, bindings, instrs) ->
CDEF_let (n, List.map (fun (id, ctyp) -> (id, f ctyp)) bindings, List.map (map_instr_ctyp f) instrs)
| CDEF_fundef (id, heap_return, args, instrs) ->
CDEF_fundef (id, heap_return, args, List.map (map_instr_ctyp f) instrs)
| CDEF_startup (id, instrs) -> CDEF_startup (id, List.map (map_instr_ctyp f) instrs)
Expand Down
1 change: 1 addition & 0 deletions test/c/let_option.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x is None()
17 changes: 17 additions & 0 deletions test/c/let_option.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default Order dec

$include <prelude.sail>
$include <string.sail>
$include <mapping.sail>

overload operator ^ = {concat_str}

let x : option(bits(32)) = None()
let y : option(bits(128)) = None()

function main() -> unit = {
match x {
Some(x) => print_endline("x is " ^ bits_str(x)),
_ => print_endline("x is None()"),
};
}

0 comments on commit e8a0373

Please sign in to comment.