mlworks icon indicating copy to clipboard operation
mlworks copied to clipboard

Internal compiler error

Open ellerh opened this issue 8 years ago • 0 comments

The compiler runs into a problem with this code even if it seems to be type-correct (SML/NJ and PolyML accept it):

functor Slice (type 'a elt
               type 'a seq
               val sub : 'a seq * int -> 'a elt) =
  struct
    datatype 'a slice = SLICE of 'a seq
    fun app f (SLICE s) = f (sub (s, 0))
  end

functor MonoSlice (type elt
                   type seq
                   val sub : seq * int -> elt) =
  struct
    structure S = Slice (type 'a elt = elt
                         type 'a seq = seq
                         val sub = sub)
    val app = S.app
    type slice = elt S.slice
    type elt = elt
  end

signature MONO_SLICE =
  sig
      type elt
      type slice
      val app : (elt -> unit) -> slice -> unit
  end

structure S : MONO_SLICE = MonoSlice (type elt = CharVector.elem
                                      type seq = CharVector.vector
                                      val sub = CharVector.sub)

For instance the interpreter stops with an "Exception Zip":

mlworks -tty
Use: /home/helmut/.mlworks
val it : unit = ()
MLWorks 2.1 Professional Edition
Copyright (C) 1999 Harlequin Group plc.  All rights reserved.
MLWorks is a trademark of Harlequin Group plc.

MLWorks> use "test.sml";
Use: /tmp/test.sml
functor MonoSlice
functor Slice
signature MONO_SLICE =
  sig
    type elt
    type slice
    val app : (elt -> unit) -> slice -> unit
  end
Entering Debugger, scanning stack ... done.
Exception Zip[_lists.sml:128.15-128.17] raised
Entering debugger, commands: q : quit (return to listener),  ? : more help
Current (innermost) stack frame:
No visible frame
Debugger> 

ellerh avatar Jan 05 '16 15:01 ellerh