I have the following snippet in my program where OCaml (3.12.1) seems to take both the branches.
let new_lst1 =
if List.length lst1 = 0 then tmp_lst1_1
else tmp_lst1_2
in
let new_lst2 =
if List.length lst2 = 0 then tmp_lst2_1
else tmp_lst2_2
in
........
The program does not terminate and when examined in ocamldebug, I see that for new_lst2 both the branches are being taken (then followed by else branch). new_lst2 gets the wrong value resulting in a non terminating loop. This happens after executing the program in debugger for a while.
I haven't found anything by searching online for OCaml. I got around this by just rewriting each if-then-else into two if-then-elses. Like let lst = if cond then lst1 else lst2
can be rewritten to let sub_lst1 = if cond then lst1 else []
and let sub_lst2 = if not cond then lst2 else []
and let lst = sub_lst1@sub_lst2
But it would nice to get to the bottom of this perplexing issue. Has anyone else encountered similar problem? Any ideas on what might be happening?
Thanks.