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

Ocaml bug #7855

Closed
vicuna opened this issue Oct 26, 2002 · 1 comment
Closed

Ocaml bug #7855

vicuna opened this issue Oct 26, 2002 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 26, 2002

Original bug ID: 1461
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Dr. Lee Hunt McDonald
Version: OCaml 3.02 and 3.06
OS: RedHat 8.0 Linux
Submission from: dsl093-162-077.tus1.dsl.speakeasy.net (66.93.162.77)

I ran the following code with OCaml 3.02 (CDK) and OCaml 3.06.
The output shows that there is a bug here.

---------- start code -------------
(* BAD.ML : string bug *)

class bad =
object
(* ---- instance variables ---- *)
val mutable myMutStr = "11";

(* ---- setters ---- *)
method chgStr : unit =
begin
myMutStr.[0] <- '2';
myMutStr.[1] <- '2';
end;

method backStr : unit = myMutStr <- "11";

(* ---- getters ---- )
method getStr : string =
begin
myMutStr;
end;
end (
end class bad *)

(*

  • -------- functional stuff for unit testing --------
    )
    let _ =
    if !(Sys.interactive) then
    ()
    else begin
    print_string "Bad behavior v0.00";
    print_newline ();
    let jj = new bad
    in begin
    jj#chgStr;
    jj#backStr;
    let x1 = jj#getStr
    in begin
    print_string ("1st =" ^ x1);
    print_newline ();
    end;
    jj#chgStr;
    jj#backStr;
    let x1 = jj#getStr
    in begin
    print_string ("2nd =" ^ x1);
    print_newline ();
    end;
    end;
    end (
    end else *)
    ----------- end code ---------------
    ----------- start shell script : this is how I compiled bad.exe -----------
    #!/bin/sh
    ocamlc -g -c bad.ml
    ocamlc -g -o bad.exe bad.cmo
    ---------- end shell script ----------
    ----------- start output (from running bad.exe) -----------
    Bad behavior v0.00
    1st =11
    2nd =22
    ----------- end output -----------
@vicuna
Copy link
Author

vicuna commented Oct 28, 2002

Comment author: administrator

User's misunderstanding. See #7872

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