Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#165] Nowhere generates incorrect SML code

Date:
2016-07-01 12:23
Priority:
3
State:
Open
Submitted by:
Bug Submitter (webuser)
Assigned to:
Allen Leung (leunga)
Machine Architecture:
x86
Operating System:
Linux
Component:
Other
Resolution:
None
Severity:
Major
OS Version:
Debian jessie
SML/NJ Version:
110.79
Keywords:
nowhere
URL:
Transcript (of reproduction):
$ 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
Source (for reproduction):
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
Summary:
Nowhere generates incorrect SML code

Detailed description
When we invoke nowhere on a small file test.now, it generates
a file test.sml that contains undefined variables. test.sml
is then rejected by the compiler.

Additional comments:
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 ()
>>>>>>>>>>>>>>>>>>>>

Submitted via web form by Hubert Garavel <hubert.garavel@inria.fr>

Comments:

No Comments Have Been Posted

Attached Files:

Changes

Field Old Value Date By
assigned_tonone2016-07-01 13:07jhr
detailsWhen we invoke nowhere on a small file test.now, it generates a file test.sml that contains undefined variables. test.sml is then rejected by the compiler. Additional comments: 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 () >>>>>>>>>>>>>>>>>>>> Submitted via web form by Hubert Garavel <hubert.garavel@inria.fr> 2016-07-01 13:07jhr
Transcript (of reproduction) $ 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 2016-07-01 13:07jhr
Source (for reproduction)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 () end2016-07-01 13:07jhr