bug: mlton: simplifyPrimExp: Case2

Christopher League league@contrapunctus.net
13 Jun 2001 10:19:39 -0400


  Dear MLton folks,

  I encountered a bug in MLton 20000906, and pruned the problem down
  to the following code:

    % cat mltonbug.sml
    val L = case Word32.wordSize 
              of 32 => ["CAFEBABE", "FFFFFFFF", "A123"] 
               | _ => []

  This looks silly on its own, but you'll have to believe that it came
  from a sensible unit test.  :)

  The verbose output of MLton appears below.  A simple workaround is
  to put the code under a lambda, where, presumably, MLton will not
  try to reduce it.  I haven't managed to build 20010125 yet, but I
  didn't see any mention of this error in the CHANGES file.

  Incidentally, this came from a little project (JVMkit, for
  processing Java class files) where I'm trying hard to support all
  the different SML systems (NJ, Moscow, Poly, MLton).  I have
  Autoconf tests to check for the presence of various basis modules,
  parameterized build scripts, etc.  That part by itself might be of
  interest to the larger SML community (once it's worthy of
  release..)

 --Chris

    % mlton -v mltonbug.sml
       compile starting
       MLton 20000906 (built on Fri Oct 20 04:08:03 2000 on syzygy.clairv.com)
          created this file on Wed Jun 13 10:02:32 2001.
       Do not edit this file.
       Flag settings: 
          aux: false
          canDefunctorize: false
          chunk: coalesce 2000
          defines: [NODEBUG]
          fixed heap: None
          global-floats: false
          indentation: 3
          includes: [mlton.h]
          inline: NonRecursive Some(50)
          inline rounds: 1
          input file: mltonbug.sml
          instrument: false
          instrument Sxml: false
          keep Cps: false
          match: left to right
          messages: true
          mode: compile
          native: false
          native-commented: false
          polyvariance: Some({rounds = 2, small = 30, product = 300})
          print at fun entry: false
          profile: false
          show types: false
       numPeeks = 187637
       average position in bucket = 0.191
       parse and elaborate starting
       parse and elaborate finished in 0.004
       core-ml size is 1,229,492 bytes
       dead starting
       dead finished in 0.006
       basis size is 48,252 bytes
       size = 383
       gcc -DNODEBUG -I/usr/local/lib/mlton/include -L/usr/local/lib/mlton/lib -O1 -w -fomit-frame-pointer -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -o /tmp/fileuH44qP /tmp/fileyIebhe.c -lmlton -lm -lgmp
       /tmp/fileuH44qP /tmp/filetXWbRE
       infer starting
          unification starting
          unification finished in 0.014
          finish infer starting
          finish infer finished in 0.021
       infer finished in 0.046
       xml.unsimplified size is 108,604 bytes
       infer simplify starting
       infer simplify raised in 0.007
    compile raised in 1.412
    mlton: simplifyPrimExp: Case2
    % echo $status
    1