Fix IL translation of pattern-alt to allow a value of mutable/constrained type to be the subject of a pattern-alt.

This commit is contained in:
Roy Frostig 2010-07-16 18:04:34 -07:00
parent 1ac01e16cf
commit c906759807
2 changed files with 7 additions and 6 deletions

View File

@ -3961,7 +3961,7 @@ let trans_visitor
| Ast.PAT_tag (lval, pats) ->
let tag_name = tag_ctor_name_to_tag_name (lval_to_name lval) in
let ty_tag =
match src_ty with
match strip_mutable_or_constrained_ty src_ty with
Ast.TY_tag tag_ty -> tag_ty
| Ast.TY_iso ti -> (ti.Ast.iso_group).(ti.Ast.iso_index)
| _ -> bug cx "expected tag type"
@ -4009,8 +4009,8 @@ let trans_visitor
| Ast.PAT_wild -> [] (* irrefutable *)
in
let (lval_cell, lval_slot) = trans_lval at.Ast.alt_tag_lval in
let next_jumps = trans_pat pat lval_cell lval_slot in
let (lval_cell, lval_ty) = trans_lval at.Ast.alt_tag_lval in
let next_jumps = trans_pat pat lval_cell lval_ty in
trans_block block;
let last_jump = mark() in
emit (Il.jmp Il.JMP Il.CodeNone);

View File

@ -390,15 +390,16 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
Ast.sprintf_ty ty
| `Module items, Ast.COMP_named ((Ast.COMP_ident id) as name_comp)
| `Module items, Ast.COMP_named ((Ast.COMP_app (id, _))
as name_comp) ->
| `Module items, Ast.COMP_named ((Ast.COMP_app (id, _))
as name_comp) ->
let mod_item =
try
Hashtbl.find items id
with Not_found ->
Common.bug
()
"internal_check_ext_lval: ident not found in mod item"
"internal_check_ext_lval: ident %s not found in mod item"
id
in
let lty =
internal_check_mod_item_decl