File: 258_tcoptimization.sml

package info (click to toggle)
smlsharp 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 123,732 kB
  • sloc: ansic: 16,725; sh: 4,347; makefile: 2,191; java: 742; haskell: 493; ruby: 305; cpp: 284; pascal: 256; ml: 255; lisp: 141; asm: 97; sql: 74
file content (47 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
fun f g = g () handle e => raise e

(*
2013-07-01 katsu

After TCOptimization, resultTy of TPHANDLE becomes a unbound type variable.

Type Inference:
val f(0) : ['a. (unit(t8[]) -> 'a) -> 'a] =
 [
  'a(36).
   fn {g(1) : unit(t8[]) -> 'a} =>
    (
      handle
        (g(1) : unit(t8[]) -> 'a) () : unit
       with
         fn $T_a(3) : exn(t13[]) =>
            case (handle) $T_a(3) : exn(t13[]) of
              e(2) : exn(t13[]) => raise e(2) : exn(t13[]) : 'a
    ) : 'a
        ^^ ***HERE***
  ]
export f(4) : (unit(t8[]) -> unit(t8[])) -> unit(t8[])
    as f : (unit -> unit) -> unit

TypedCalc Optimized:
val f(4) : (unit(t8[]) -> unit(t8[])) -> unit(t8[]) =
 (fn g(5) : unit(t8[]) -> unit(t8[]) =>
  (
    handle
      (g(5) : unit(t8[]) -> unit(t8[])) () : unit
    with
      fn $T_a(6) : exn(t13[]) =>
         case (handle) $T_a(6) : exn(t13[]) of
           e(7) : exn(t13[]) => raise e(7) : exn(t13[]) : unit
  ) : FREEBTV(36)
      ^^^^^^^^^^^
 ) : unit
export f(4) : (unit(t8[]) -> unit(t8[])) -> unit(t8[])
    as f : (unit -> unit) -> unit

*)

(*
2013-07-02 ohori
Fixed by 5216:8@7595dc04945 and 5215:4bfa51146b76
*)