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

Module name leak in nested types #59

Open
mrmr1993 opened this issue Dec 28, 2020 · 2 comments
Open

Module name leak in nested types #59

mrmr1993 opened this issue Dec 28, 2020 · 2 comments

Comments

@mrmr1993
Copy link

When a function accepts multiple implicit arguments and their types nest as type parameters, the later implicit argument is not resolved. This appears to be an actual failure rather than a printing error: see the last evaluation.

$ rlwrap boot/ocamlrun ./ocaml -nostdlib -I stdlib -noinit
        OCaml version 4.02.1+dev0-2014-08-29

# module type TYPE1 = sig type _ t end;;
module type TYPE1 = sig type _ t end
# let f {M : TYPE1} {N : TYPE1} (x : int M.t N.t M.t) = x;;
val f : {M : TYPE1} -> {N : TYPE1} -> int M.t N.t M.t -> int M.t N.t M.t =
  <fun>
# implicit module Option_type = struct type 'a t = 'a option end;;
implicit module Option_type : sig type 'a t = 'a option end
# f {Option_type} {Option_type};;
- : int Option_type.t N.t Option_type.t ->
    int Option_type.t N.t Option_type.t
= <fun>
# let g x = f x;;
val g :
  int Option_type.t N.t Option_type.t -> int Option_type.t N.t Option_type.t =
  <fun>
# g (Some (Some (Some 15)));;
Error: This expression has type 'a option
       but an expression was expected of type int Option_type.t N.t
@lpw25
Copy link
Member

lpw25 commented Dec 28, 2020

Interesting. @trefis since he's been working on a rebased version of the prototype recently and I'm not sure he is following this repo.

@yallop
Copy link
Contributor

yallop commented Sep 12, 2023

Possibly the same bug (discovered by @dvlasits and @pxeger):

module type Mk = sig type 'a t val mk : 'a -> 'a t end
module type T = sig type t end
module Lst = struct type 'a t = 'a list let mk x = [x] end

let test {M : Mk} {T : T} (f : T.t) : T.t M.t = M.mk f
let test2 = test {Lst} {Int64} 0L

This gives

val test : {M : Mk} -> {T : T} -> T.t -> T.t M.t = <fun>
val test2 : T.t Lst.t = [<abstr>]

i.e. the type T.t in the return type of test is not resolved to Int64 in the call from test2.

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

No branches or pull requests

3 participants