#829204 nowhere generates incorrect SML code

Package:
nowhere
Source:
smlnj
Description:
Translates programs from an extended Standard ML to Standard ML
Submitter:
Hubert Garavel
Date:
2026-09-26 19:09:01 UTC
Severity:
normal
Tags:
#829204#5
Date:
2016-07-01 11:58:08 UTC
From:
To:
When we invoke nowhere on a small file test.now, it generates
a file test.sml that contains undefined variable. test.sml
is then rejected by the compiler.

This is an example of problematic file test.now

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
local

datatype xbool = Xtrue | Xfalse
and strg = Xa | Xb | C of strg * strg;
in
datatype xbool = Xtrue | Xfalse
and strg = Xa | Xb | C of strg * strg;

fun gte (x1:strg, x2:strg ): xbool =
case (x1, x2) of
(Xa, Xa) => Xtrue
| (C (e, s), e2) => gte (e, e2)
| (e, C (e2, s2)) where e = e2 => Xfalse

fun main () =(
  print "\n"
)

val _ = main ()

end
(x86, 32 bits):

$ /usr/bin/nowhere @SMLversion
nowhere 110.76

$ /usr/bin/sml @SMLversion
sml 110.76

$ /usr/bin/nowhere test.now
test.now:9.1-13.41: warning: non-exhaustive matches
(Xa, Xa) => ...
(C(e, s), e2) => ...
(e, C(e2, s2)) where ... => ...
[Generating test.sml]

The generated SML file contains references to undefined variables
v_1 and v_5, and is then rejected by the SML compiler:

$ /usr/bin/sml test.sml
Standard ML of New Jersey v110.76 [built: Mon Jul 7 16:22:48 2014]
[opening test.sml]
test.now:14.34-14.37 Error: unbound variable or constructor: v_1
test.now:16.28-16.31 Error: unbound variable or constructor: v_5
/usr/lib/smlnj/bin/sml: Fatal error -- Uncaught exception Error with 0
raised at ../compiler/TopLevel/interact/evalloop.sml:66.19-66.27


We observed also the same issue on the latest version 110.79 of
Nowhere and SML:

$ nowhere test.now
test.now:9.1-13.41: warning: non-exhaustive matches
(Xa, Xa) => ...
(C(e, s), e2) => ...
(e, C(e2, s2)) where ... => ...
[Generating test.sml]

$ sml test.sml
Standard ML of New Jersey v110.79 [built: Thu Jun 23 15:18:54 2016]
[opening test.sml]
test.now:14.34-14.37 Error: unbound variable or constructor: v_1
test.now:16.28-16.31 Error: unbound variable or constructor: v_5
/home/mtabikh/SML/bin/sml: Fatal error -- Uncaught exception Error with 0
raised at ../compiler/TopLevel/interact/evalloop.sml:66.19-66.27


Enclosed is the generated file test.sml:

<<<<<<<<<<<<<<<<<<<<
(* WARNING: this is generated by running 'nowhere test.now'.
 * Do not edit this file directly.
 * Version 1.2.2
 *)

(*#line 6.1 "test.now"*)
datatype xbool =
  Xtrue
| Xfalse
    and strg =
  Xa
| Xb
| C of strg * strg

(*#line 9.1 "test.now"*)
fun gte ((x1:strg), (x2:strg)) = (
    let val v_6 = (x1, x2)
        fun state_0 () = raise Match
        fun state_8 () =
            let val (v_8, v_7) = v_1
            in
               let val e = v_5
                   and e2 = v_8
                   and s2 = v_7
               in (if (e = e2)
                     then Xfalse
                     else (state_0 ()))
               end
            end
    in
       let val (v_5, v_0) = v_6
       in
          (case v_5 of
            C v_4 =>
            let val (v_3, v_2) = v_4
            in
               let val e = v_3
                   and e2 = v_0
                   and s = v_2
               in gte (e, e2)
               end
            end
          | Xa =>
            (case v_0 of
              C v_1 => state_8 ()
            | Xa => Xtrue
            | Xb => state_0 ()
            )
          | Xb =>
            (case v_0 of
              C v_1 => state_8 ()
            | _ => state_0 ()
            )
          )
       end
    end : xbool)

(*#line 15.1 "test.now"*)
fun main () = print "\n"

(*#line 19.1 "test.now"*)
val _ = main ()

Best regards
Hubert Garavel and Mohammad-Ali Tabikh

#829204#16
Date:
2026-09-26 19:06:10 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
smlnj, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 829204@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Barak A. Pearlmutter <bap@debian.org> (supplier of updated smlnj package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Sat, 26 Sep 2026 19:15:13 +0100
Source: smlnj
Architecture: source
Version: 110.99.9-2
Distribution: unstable
Urgency: medium
Maintainer: Barak A. Pearlmutter <bap@debian.org>
Changed-By: Barak A. Pearlmutter <bap@debian.org>
Closes: 829204
Changes:
 smlnj (110.99.9-2) unstable; urgency=medium
 .
   * nowhere: fix match compiler unbound vars bug (closes: #829204)
   * Make build reproducible, so package can migrate to testing:
     + patch 0006: derive compilation unit GUIDs from SOURCE_DATE_EPOCH,
       and discard the bootstrap compiler's GUIDs before the second stage
     + patch 0007: reproducible footer in the generated MLRISC HTML
     + patch 0008: do not record build-time timings in exported heap images
     + patch 0009: keep the process id out of ml-build temporary file names
     + FORCE_SOURCE_DATE=1, so LaTeX dates follow SOURCE_DATE_EPOCH
     + debian/rules build heap images with ASLR off, pinned to one CPU, and
       with a pipe on stdout (SML records its file position in the image)
   * Point patch Forwarded headers at upstream pull requests
Checksums-Sha1:
 bdb4b4abec8a1678778171b28f231579c3ce9715 3426 smlnj_110.99.9-2.dsc
 6c5e600fd268183673fdc544f27c20a47f7904ce 23540 smlnj_110.99.9-2.debian.tar.xz
 494e0ef183e4675296ac648cd1e8774b840944ae 51271096 smlnj_110.99.9-2.git.tar.xz
 2ab58de63dcb1730ac88dc611aa4fd41f48f14a5 17728 smlnj_110.99.9-2_source.buildinfo
Checksums-Sha256:
 f6c8e73660e3ab542066eca4e38c509d97fccdffa99668a790ed8e0f1b0f4f6b 3426 smlnj_110.99.9-2.dsc
 27e068fc53410878a2c5df3841cf7d513be6db02a52594a6785e717a85e5ad9b 23540 smlnj_110.99.9-2.debian.tar.xz
 fe1dddf8fac6f7090a02c13ba87bca5a6eb42003021d9900bfb59e7fb9c393b6 51271096 smlnj_110.99.9-2.git.tar.xz
 709e597b99049d8481050a638d06b5c061f19647be8a04489f878130477c1905 17728 smlnj_110.99.9-2_source.buildinfo
Files:
 6de88fec1c24df18f0081e7cf25a400b 3426 devel optional smlnj_110.99.9-2.dsc
 76b2398dbebd8b5e30d6503db0897674 23540 devel optional smlnj_110.99.9-2.debian.tar.xz
 e60b0fe2f4013161c1fed4e7650df65b 51271096 devel None smlnj_110.99.9-2.git.tar.xz
 32618fc95d3b181a014e11baa1fec852 17728 devel optional smlnj_110.99.9-2_source.buildinfo
Git-Tag-Info: tag=02ba11b943c7b8fc9323ac7cf8c8719cb7244d32 fp=2de4bf05421076c47ad20367c6af2490d3ca72b9
Git-Tag-Tagger: Barak A. Pearlmutter <barak+git@pearlmutter.net>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEN02M5NuW6cvUwJcqYG0ITkaDwHkFAmq4FG8ACgkQYG0ITkaD
wHkYYg//ad6N7iigMUGVfnRnesVPR7iRUtcpCzUtFKFquk1dYbhhsVt2v5RkKIJc
wEt2/9f1q84LdGbiDFMjt1Md961tHGSD9DsG+scqbsCo8zK/laOnFQ4HV14XcDBq
HykJ34fSa+g6KawI3O10GVmopL/RgYZQDazFfovl44m4qOteSXbjo08ZBQYNOTeC
ZYqxh5dFR2S2ebNxY6JN+6aiWPfTcNYsA1AOzR8D/dnclIm/3GZ7lM3a7r8dSn0t
YWIaBG0sf4itNBtceaZAP3bZI4l7KD2i9ilxsmi+7kmEE/n93f3VDhfInndzGDpc
ruuXLckRhSzEV62QlSDNj8lY/tiVKprbXQdRVvCgviSBNNrXZWEBYgtU9wzZllR9
97EN20ZSzuCIcKljBcGKgb5ayA9165qoxFq206JX5x5d2aVD4JI41tEBySBvBNBq
Jz5rIg7TcViEPM+7Ap5HMymbLgS2fit/vJ0/hTypdtujC4JbSGVefkgF3edWAAAV
fvaJAeS6mnXyNKJakWdKL55h/vp4gjzW3LU91f682ERUv/SZ6mLgl1qfRqeIrNDc
Fi2pf8wVMRWAaK3fwapXLftpMLqjJjvB3/xBRRxRm9f7QfFwuTKf38RMGNlb4qQY
1XTg2tDhz7W1HdveAx+O0z+10nWsXjUrDsUAwFrwnITClFlpEIM=
=ml77
-----END PGP SIGNATURE-----