Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006211OCamlOCaml backend (code generation)public2013-10-25 08:092013-10-25 11:38
ReporterHiroaki Yamanouchi 
Assigned To 
PriorityhighSeveritymajorReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Product Version3.11.2 
Target VersionFixed in Version 
Summary0006211: An unexpected behavior in toplevel: combination of consecutive let bindings and exceptions
DescriptionAn 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;;

Exception: Division_by_zero.

# x;;

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;;

Exception: Division_by_zero.

# x;;

- : int = 3 (* I suppose that the result should be 1 *)
Steps To ReproduceAt toplevel, input the following codes.

1. "let x = 1;;"
2. "let x = 3 let y = 1 / 0;;"
3. "x;;"
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010526)
garrigue (manager)
2013-10-25 09:59

This is a "serious" bug:

# let x = "hello";;
val x : string = "hello"
# let x = 2 let y = 1/0;;
Exception: Division_by_zero.
# x;;
Segmentation fault
(0010527)
garrigue (manager)
2013-10-25 10:28

I see two ways to fix this:

1) generalize the approach taken for modules of using a unique name for toplevel values

or

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.

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker