|Anonymous | Login | Signup for a new account||2013-12-07 11:56 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006211||OCaml||OCaml backend (code generation)||public||2013-10-25 08:09||2013-10-25 11:38|
|Target Version||Fixed in Version|
|Summary||0006211: An unexpected behavior in toplevel: combination of consecutive let bindings and exceptions|
|Description||An unexpected behavior in consecutive let bindings at toplevel, say, “let x1 = e1 let x2 = e2;;”. If e2 raises an exception, the result of “x;;” afterwards depends on whether x1 had been already bound before the evaluation of the first phrase.|
----- Here is a case when a variable is not bound. -----
(* x is not bound *)
# let x = 2 let y = 1 / 0;;
Error: Unbound value x
----- Here is a case when a variable is bound. -----
# let x = 1;;
val x : int = 1
(* now, x is bound to 1 *)
# let x = 3 let y = 1 / 0;;
- : int = 3 (* I suppose that the result should be 1 *)
|Steps To Reproduce||At toplevel, input the following codes.|
1. "let x = 1;;"
2. "let x = 3 let y = 1 / 0;;"
|Tags||No tags attached.|
This is a "serious" bug:
# let x = "hello";;
val x : string = "hello"
# let x = 2 let y = 1/0;;
I see two ways to fix this:
1) generalize the approach taken for modules of using a unique name for toplevel values
2) remember old values and backtrack in case of failure
Personally I would prefer (1), as it is looks like the "right" thing.
However, IIRC correctly, the goal of the current approach of using just a string is to avoid memory leaks.
We would probably have to do something about that too.
WIth (2), we get this for free.
|2013-10-25 08:09||Hiroaki Yamanouchi||New Issue|
|2013-10-25 09:59||garrigue||Note Added: 0010526|
|2013-10-25 10:28||garrigue||Note Added: 0010527|
|Copyright © 2000 - 2011 MantisBT Group|