File: Test147.ML

package info (click to toggle)
polyml 5.7.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,584 kB
  • sloc: cpp: 44,143; ansic: 26,963; sh: 22,002; asm: 13,486; makefile: 602; exp: 525; python: 253; awk: 91
file content (31 lines) | stat: -rw-r--r-- 928 bytes parent folder | download | duplicates (5)
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
(* Bug in optimiser transformation.  A function argument that returns a tuple
   can be transformed to take a container but only if it is not curried. *)

(* Cut down example from Isabelle that caused an internal error exception. *)

fun one _ [] = raise Fail "bad"
  | one pred (x :: xs) =
      if pred x then (x, xs) else raise Fail "bad";

fun foo (scan, f) xs = let val (x, y) = scan xs in (f x, y) end;
  
fun bar (scan1, scan2) xs =
  let
    val (x, ys) = scan1 xs;
    val (y, zs) = scan2 x ys;
  in ((x, y), zs) end;

fun bub (scan1, scan2) = foo(bar(scan1, (fn _ => scan2)), op ^);

val qqq: string list -> string * int = bub(one (fn _ => raise Match), (foo((fn _ => raise Match), String.concat)));

(* Further example - This caused a segfault. *)

PolyML.Compiler.maxInlineSize := 1;
fun f g = let val (x,y) = g 1 2 in x+y end;

fun r (x, y, z) = fn _ => (x, y+z);

val h: int-> int*int = r (4,5,6);

f (fn _ => h);