Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected memorization of an optional label. #4426

Closed
vicuna opened this issue Oct 20, 2007 · 3 comments
Closed

Unexpected memorization of an optional label. #4426

vicuna opened this issue Oct 20, 2007 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 20, 2007

Original bug ID: 4426
Reporter: jm
Status: closed (set by @garrigue on 2007-10-29T06:57:54Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: i686
OS: Debian
OS Version: Sid
Version: 3.10+dev
Fixed in version: 3.10+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: jm

Bug description

In the example below, the optional argument ?l of class ko shouldn't be memorized at the first instantiation.

Steps to reproduce

% ocaml
Objective Caml version 3.10.1+dev0 (2007-05-21)

class i ?(l=fun () -> 0) () =

object val v = l () method v = v
initializer prerr_endline ("v="^string_of_int v)
end;;
class i : ?l:(unit -> int) -> unit -> object val v : int method v : int end

class ko ?l = i ~l: (fun () -> (object inherit i () ?l end)#v + 1)

class ok ?l = i ~l: ((fun ?l () -> (object inherit i () ?l end)#v + 1) ?l)
;;
class ko : ?l:(unit -> int) -> unit -> i
class ok : ?l:(unit -> int) -> unit -> i

new ko () ~l: (fun _ -> 42);;

v=42
v=43

  • : ko =

new ko ();;

v=42
v=43

  • : ko =

new ko () ~l: (fun _ -> 24);;

v=42
v=43

  • : ko =

new ok () ~l: (fun _ -> 42);;

v=42
v=43

  • : ok =

new ok ();;

v=0
v=1

  • : ok =

new ok () ~l: (fun _ -> 24);;

v=24
v=25

  • : ok =
@vicuna
Copy link
Author

vicuna commented Oct 29, 2007

Comment author: @garrigue

I see no attached example...

@vicuna
Copy link
Author

vicuna commented Oct 29, 2007

Comment author: jm

It is because the example is inside the field "Steps to reproduce" hidden in the advanced view:
http://caml.inria.fr/mantis/bug_view_advanced_page.php?bug_id=4426

@vicuna
Copy link
Author

vicuna commented Oct 29, 2007

Comment author: @garrigue

Fixed in branch release310 (typing/typeclass.ml)
Environment declared by class functions was incorrect.

@vicuna vicuna closed this as completed Oct 29, 2007
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant