Debian Codegraph @

doc/guide/src/UnresolvedBugs.adoc

raw
1 = UnresolvedBugs
2
3 Here are the places where MLton deviates from
4 <<DefinitionOfStandardML#,The Definition of Standard ML (Revised)>> and
5 the <<BasisLibrary#,Basis Library>>. In general, MLton complies with
6 the <<DefinitionOfStandardML#,Definition>> quite closely, typically much
7 more closely than other SML compilers (see, e.g., our list of
8 <<SMLNJDeviations#,SML/NJ's deviations>>). In fact, the four deviations
9 listed here are the only known deviations, and we have no immediate
10 plans to fix them. If you find a deviation not listed here, please
11 report a <<Bug#>>.
12
13 We don't plan to fix these bugs because the first (parsing nested
14 cases) has historically never been accepted by any SML compiler, the
15 second clearly indicates a problem in the
16 <<DefinitionOfStandardML#,Definition>>, and the remaining are difficult
17 to resolve in the context of MLton's implementaton of Standard ML (and
18 unlikely to be problematic in practice).
19
20 * MLton does not correctly parse case expressions nested within other
21 matches. For example, the following fails.
22 +
23 [source,sml]
24 ----
25 fun f 0 y =
26 case x of
27 1 => 2
28 | _ => 3
29 | f _ y = 4
30 ----
31 +
32 To do this in a program, simply parenthesize the case expression.
33 +
34 Allowing such expressions, although compliant with the Definition,
35 would be a mistake, since using parentheses is clearer and no SML
36 compiler has ever allowed them. Furthermore, implementing this would
37 require serious yacc grammar rewriting followed by postprocessing.
38
39 * MLton does not raise the `Bind` exception at run time when
40 evaluating `val rec` (and `fun`) declarations that redefine
41 identifiers that previously had constructor status. (By default,
42 MLton does warn at compile time about `val rec` (and `fun`)
43 declarations that redefine identifiers that previously had
44 constructors status; see the `valrecConstr` <<MLBasisAnnotations#,ML
45 Basis annotation>>.) For example, the Definition requires the
46 following program to type check, but also (bizarelly) requires it to
47 raise the `Bind` exception
48 +
49 [source,sml]
50 ----
51 val rec NONE = fn () => ()
52 ----
53 +
54 The Definition's behavior is obviously an error, a mismatch between
55 the static semantics (rule 26) and the dynamic semantics (rule 126).
56 Given the comments on rule 26 in the Definition, it seems clear that
57 the authors meant for `val rec` to allow an identifier's constructor
58 status to be overridden both statically and dynamically. Hence, MLton
59 and most SML compilers follow rule 26, but do not follow rule 126.
60
61 * MLton does not hide the equality aspect of types declared in
62 `abstype` declarations. So, MLton accepts programs like the following,
63 while the Definition rejects them.
64 +
65 [source,sml]
66 ----
67 abstype t = T with end
68 val _ = fn (t1, t2 : t) => t1 = t2
69
70 abstype t = T with val a = T end
71 val _ = a = a
72 ----
73 +
74 One consequence of this choice is that MLton accepts the following
75 program, in accordance with the Definition.
76 +
77 [source,sml]
78 ----
79 abstype t = T with val eq = op = end
80 val _ = fn (t1, t2 : t) => eq (t1, t2)
81 ----
82 +
83 Other implementations will typically reject this program, because they
84 make an early choice for the type of `eq` to be `''a * ''a \-> bool`
85 instead of `t * t \-> bool`. The choice is understandable, since the
86 Definition accepts the following program.
87 +
88 [source,sml]
89 ----
90 abstype t = T with val eq = op = end
91 val _ = eq (1, 2)
92 ----
93 +
94
95 * MLton (re-)type checks each functor definition at every
96 corresponding functor application (the compilation technique of
97 defunctorization). One consequence of this implementation is that
98 MLton accepts the following program, while the Definition rejects
99 it.
100 +
101 [source,sml]
102 ----
103 functor F (X: sig type t end) = struct
104 val f = id id
105 end
106 structure A = F (struct type t = int end)
107 structure B = F (struct type t = bool end)
108 val _ = A.f 10
109 val _ = B.f "dude"
110 ----
111 +
112 On the other hand, other implementations will typically reject the
113 following program, while MLton and the Definition accept it.
114 +
115 [source,sml]
116 ----
117 functor F (X: sig type t end) = struct
118 val f = id id
119 end
120 structure A = F (struct type t = int end)
121 structure B = F (struct type t = bool end)
122 val _ = A.f 10
123 val _ = B.f false
124 ----
125 +
126 See <<References#DreyerBlume07,DreyerBlume07>> for more details.