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

Variant pattern matching bug #2967

Closed
vicuna opened this issue Sep 21, 2001 · 2 comments
Closed

Variant pattern matching bug #2967

vicuna opened this issue Sep 21, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 21, 2001

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

Bug description

Full_Name: Manuel Fahndrich
Version: 3.02
OS: W2K
Submission from: atoms.research.microsoft.com (131.107.65.127)

The following code produces the wrong output, and also crashes ocamlrun. Slight
modifications do not produce the bug.


type type_expr = [
| TTuple of type_expr list | TConstr of type_expr list
| TVar of string | TVariant of string list
| TBlock of int | TCopy of type_expr
]

and recurs_type_expr = [
| TTuple of type_expr list | TConstr of type_expr list
| `TVariant of string list
]

let rec copyit te =
match te with
| TCopy te -> te | TVar _ -> te
| `TBlock _ -> te
| #recurs_type_expr as desc ->

Printf.printf "should not be here";
flush stdout;

let te =
  (match desc with
    `TTuple tl ->
      `TTuple (List.map copyit tl)
  | `TConstr tl ->
      `TConstr (List.map (copyit) tl)
  | `TVariant (row) ->
      `TVariant (row)
	)
in

te

let _ = copyit (`TVar "Test")


@vicuna
Copy link
Author

vicuna commented Sep 21, 2001

Comment author: administrator

Full_Name: Manuel Fahndrich
Version: 3.02
OS: W2K
Submission from: atoms.research.microsoft.com (131.107.65.127)

The following code produces the wrong output, and also crashes ocamlrun. Slight
modifications do not produce the bug.


type type_expr = [
| TTuple of type_expr list | TConstr of type_expr list
| TVar of string | TVariant of string list
| TBlock of int | TCopy of type_expr
]

and recurs_type_expr = [
| TTuple of type_expr list | TConstr of type_expr list
| `TVariant of string list
]

let rec copyit te =
match te with
| TCopy te -> te | TVar _ -> te
| `TBlock _ -> te
| #recurs_type_expr as desc ->

Printf.printf "should not be here";
flush stdout;

let te =
(match desc with
TTuple tl -> TTuple (List.map copyit tl)
| TConstr tl -> TConstr (List.map (copyit) tl)
| TVariant (row) -> TVariant (row)
)
in

te

let _ = copyit (`TVar "Test")


This is a bug (not limited to W2k) and I am working on it.
Thank you for having reported the bug.

--Luc

@vicuna
Copy link
Author

vicuna commented Sep 21, 2001

Comment author: administrator

Fixed on 21-11-2001 --Luc

@vicuna vicuna closed this as completed Sep 21, 2001
@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