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

référence et polymorphisme #8391

Closed
vicuna opened this issue Dec 1, 2003 · 3 comments
Closed

référence et polymorphisme #8391

vicuna opened this issue Dec 1, 2003 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Dec 1, 2003

Original bug ID: 1952
Reporter: administrator
Status: resolved (set by @damiendoligez on 2013-08-30T21:12:28Z)
Resolution: suspended
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Related to: #6150
Monitored by: "Julien Signoles"

Bug description

Full_Name: Julien Signoles
Version: 3.06 et 3.07
OS: linux
Submission from: newwww.lri.fr (129.175.15.10)

Bonjour,

Le programme ci-dessous ne type pas alors qu'il devrait...

=====
let x = ref 0
let y = ref true

let f a = x := a
let g a = y := a

(* version "typage explicite + let" : ok *)
let h1 : ('a -> unit) -> 'a -> unit = fun f x -> f x;;
h1 f 0;;
h1 g true;;

let _ =
(* version "typage implicite + let_in" : ok )
let h1 f x = f x in
h1 f 0;
h1 g true;
(
version "typage explicite + let_in" : KO )
let h2 : ('a -> unit) -> 'a -> unit = fun f x -> f x in
h2 f 0;
h2 g (
<-- erreur de typage *) true

Julien Signoles

@vicuna
Copy link
Author

vicuna commented May 28, 2004

Comment author: administrator

Le programme ci-dessous ne type pas alors qu'il devrait...

=====
let x = ref 0
let y = ref true

let f a = x := a
let g a = y := a

let _ =
(* version "typage explicite + let_in" : KO )
let h2 : ('a -> unit) -> 'a -> unit = fun f x -> f x in
h2 f 0;
h2 g (
<-- erreur de typage *) true

Ce n'est pas a proprement parler un bug, puisque c'est le comportement prevu du
compilateur (mais je ne suis pas sur qu'il soit clairement documente').
Toutes les variables de types apparaissant dans des annotations sont
considerees
comme liees au niveau le plus exterieur. Elles ne peuvent donc etre rendues
polymorphes que pour les definitions a` toplevel.
Il est parfois question de changer cette semantique... je reclasse donc ca en
feature-wish.

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented May 28, 2004

Comment author: administrator

Question de liaison des variables dans les contraintes de types ? -DD
Oui, mais ce n'est pas un bug -JG

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @damiendoligez

This particular example is resolved by explicit polymorphism, which was introduced in the meantime. Change the type annotation to:
h2 : 'a . ('a -> unit) -> 'a -> unit
and the program typechecks.

I don't know whether we are still considering a change in the binding rule for type annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant