Browse Source

[java/cs] Handle empty switches

Cauê Waneck 11 years ago
parent
commit
ae28f79fa0
1 changed files with 6 additions and 2 deletions
  1. 6 2
      gencommon.ml

+ 6 - 2
gencommon.ml

@@ -9154,11 +9154,15 @@ struct
               | (conds,e) :: tl ->
               | (conds,e) :: tl ->
                 { eexpr = TIf(mk_many_cond conds, run e, Some(loop tl)); etype = e.etype; epos = e.epos }
                 { eexpr = TIf(mk_many_cond conds, run e, Some(loop tl)); etype = e.etype; epos = e.epos }
               | [] -> match default with
               | [] -> match default with
-                | None -> gen.gcon.error "Empty switch" e.epos; assert false
+                | None ->
+									raise Exit
                 | Some d -> run d
                 | Some d -> run d
             in
             in
 
 
-            { e with eexpr = TBlock(fst_block @ [loop cases]) }
+						try
+							{ e with eexpr = TBlock(fst_block @ [loop cases]) }
+						with | Exit ->
+							{ e with eexpr = TBlock [] }
           end
           end
         | _ -> Type.map_expr run e
         | _ -> Type.map_expr run e
     in
     in