<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.10">
<title>UnresolvedBugs</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css">
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20201002</a>
</div>
</div>
<div id="header">
<h1>UnresolvedBugs</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>Here are the places where MLton deviates from
<a href="DefinitionOfStandardML">The Definition of Standard ML (Revised)</a> and
the <a href="BasisLibrary">Basis Library</a>.  In general, MLton complies with
the <a href="DefinitionOfStandardML">Definition</a> quite closely, typically much
more closely than other SML compilers (see, e.g., our list of
<a href="SMLNJDeviations">SML/NJ&#8217;s deviations</a>).  In fact, the four deviations
listed here are the only known deviations, and we have no immediate
plans to fix them.  If you find a deviation not listed here, please
report a <a href="Bug">Bug</a>.</p></div>
<div class="paragraph"><p>We don&#8217;t plan to fix these bugs because the first (parsing nested
cases) has historically never been accepted by any SML compiler, the
second clearly indicates a problem in the
<a href="DefinitionOfStandardML">Definition</a>, and the remaining are difficult
to resolve in the context of MLton&#8217;s implementaton of Standard ML (and
unlikely to be problematic in practice).</p></div>
<div class="ulist"><ul>
<li>
<p>
MLton does not correctly parse case expressions nested within other
matches. For example, the following fails.
</p>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">fun</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">      </span><span class="k">case</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="k">of</span><span class="w"></span>
<span class="w">         </span><span class="mi">1</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="mi">2</span><span class="w"></span>
<span class="w">       </span><span class="p">|</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="mi">3</span><span class="w"></span>
<span class="w">  </span><span class="p">|</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mi">4</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>To do this in a program, simply parenthesize the case expression.</p></div>
<div class="paragraph"><p>Allowing such expressions, although compliant with the Definition,
would be a mistake, since using parentheses is clearer and no SML
compiler has ever allowed them.  Furthermore, implementing this would
require serious yacc grammar rewriting followed by postprocessing.</p></div>
</li>
<li>
<p>
MLton does not raise the <span class="monospaced">Bind</span> exception at run time when
evaluating <span class="monospaced">val rec</span> (and <span class="monospaced">fun</span>) declarations that redefine
identifiers that previously had constructor status.  (By default,
MLton does warn at compile time about <span class="monospaced">val rec</span> (and <span class="monospaced">fun</span>)
declarations that redefine identifiers that previously had
constructors status; see the <span class="monospaced">valrecConstr</span> <a href="MLBasisAnnotations">ML
Basis annotation</a>.)  For example, the Definition requires the
following program to type check, but also (bizarelly) requires it to
raise the <span class="monospaced">Bind</span> exception
</p>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">val</span><span class="w"> </span><span class="k">rec</span><span class="w"> </span><span class="n">NONE</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="p">()</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>The Definition&#8217;s behavior is obviously an error, a mismatch between
the static semantics (rule 26) and the dynamic semantics (rule 126).
Given the comments on rule 26 in the Definition, it seems clear that
the authors meant for <span class="monospaced">val rec</span> to allow an identifier&#8217;s constructor
status to be overridden both statically and dynamically.  Hence, MLton
and most SML compilers follow rule 26, but do not follow rule 126.</p></div>
</li>
<li>
<p>
MLton does not hide the equality aspect of types declared in
<span class="monospaced">abstype</span> declarations. So, MLton accepts programs like the following,
while the Definition rejects them.
</p>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">abstype</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="k">end</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">t1</span><span class="p">,</span><span class="w"> </span><span class="n">t2</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">t2</span><span class="w"></span>

<span class="k">abstype</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="k">val</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">end</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">a</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>One consequence of this choice is that MLton accepts the following
program, in accordance with the Definition.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">abstype</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="k">val</span><span class="w"> </span><span class="n">eq</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">op</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">end</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">t1</span><span class="p">,</span><span class="w"> </span><span class="n">t2</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">eq</span><span class="w"> </span><span class="p">(</span><span class="n">t1</span><span class="p">,</span><span class="w"> </span><span class="n">t2</span><span class="p">)</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>Other implementations will typically reject this program, because they
make an early choice for the type of <span class="monospaced">eq</span> to be <span class="monospaced">''a * ''a -&gt; bool</span>
instead of <span class="monospaced">t * t -&gt; bool</span>.  The choice is understandable, since the
Definition accepts the following program.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">abstype</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="k">val</span><span class="w"> </span><span class="n">eq</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">op</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">end</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">eq</span><span class="w"> </span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="w"></span>
</pre></div></div></div>
</li>
<li>
<p>
MLton (re-)type checks each functor definition at every
corresponding functor application (the compilation technique of
defunctorization).  One consequence of this implementation is that
MLton accepts the following program, while the Definition rejects
it.
</p>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">functor</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="p">(</span><span class="n">X</span><span class="p">:</span><span class="w"> </span><span class="k">sig</span><span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="k">end</span><span class="p">)</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">struct</span><span class="w"></span>
<span class="w">    </span><span class="k">val</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">id</span><span class="w"> </span><span class="n">id</span><span class="w"></span>
<span class="k">end</span><span class="w"></span>
<span class="k">structure</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">int</span><span class="w"> </span><span class="k">end</span><span class="p">)</span><span class="w"></span>
<span class="k">structure</span><span class="w"> </span><span class="n">B</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">bool</span><span class="w"> </span><span class="k">end</span><span class="p">)</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">A</span><span class="p">.</span><span class="n">f</span><span class="w"> </span><span class="mi">10</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">B</span><span class="p">.</span><span class="n">f</span><span class="w"> </span><span class="s">&quot;dude&quot;</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>On the other hand, other implementations will typically reject the
following program, while MLton and the Definition accept it.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">functor</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="p">(</span><span class="n">X</span><span class="p">:</span><span class="w"> </span><span class="k">sig</span><span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="k">end</span><span class="p">)</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">struct</span><span class="w"></span>
<span class="w">    </span><span class="k">val</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">id</span><span class="w"> </span><span class="n">id</span><span class="w"></span>
<span class="k">end</span><span class="w"></span>
<span class="k">structure</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">int</span><span class="w"> </span><span class="k">end</span><span class="p">)</span><span class="w"></span>
<span class="k">structure</span><span class="w"> </span><span class="n">B</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">bool</span><span class="w"> </span><span class="k">end</span><span class="p">)</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">A</span><span class="p">.</span><span class="n">f</span><span class="w"> </span><span class="mi">10</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">B</span><span class="p">.</span><span class="n">f</span><span class="w"> </span><span class="n">false</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>See <a href="References#DreyerBlume07">DreyerBlume07</a> for more details.</p></div>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
