Skip to content

Commit 653bec9

Browse files
authored
Merge pull request #1046 from Julow/fix-crash-functor-alias
Fix crash on functor returning an alias
2 parents f37f163 + 7dd7fe6 commit 653bec9

16 files changed

+393
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Tags:
1717

1818
### Fixed
1919

20+
- Fix crash on functors returning an alias (@Julow, #1046)
2021
- Fix rendering of polymorphic variants (@wikku, @panglesd, #971)
2122
- Add references to extension declarations (@gpetiot, @panglesd, #949)
2223

src/loader/cmi.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,9 @@ let rec read_module_type env parent (mty : Odoc_model.Compat.module_type) =
938938
in
939939
let res = read_module_type env (Identifier.Mk.result parent) res in
940940
Functor( f_parameter, res)
941-
| Mty_alias _ -> assert false
941+
| Mty_alias p ->
942+
let t_desc = ModPath (Env.Path.read_module env p) in
943+
TypeOf { t_desc; t_expansion = None }
942944

943945
and read_module_type_declaration env parent id (mtd : Odoc_model.Compat.modtype_declaration) =
944946
let open ModuleType in

test/generators/cases/functor_ml.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Foo (X : sig
2+
val foo : int
3+
end) =
4+
String
5+
6+
module Bar = struct
7+
type t
8+
end
9+
10+
module Foo' (X : sig
11+
val foo : int
12+
end) =
13+
Bar
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head><title>Bar (Functor_ml.Bar)</title>
4+
<link rel="stylesheet" href="odoc.css"/><meta charset="utf-8"/>
5+
<meta name="generator" content="odoc %%VERSION%%"/>
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
7+
<script src="highlight.pack.js"></script>
8+
<script>hljs.initHighlightingOnLoad();</script>
9+
</head>
10+
<body class="odoc">
11+
<nav class="odoc-nav"><a href="Functor_ml.html">Up</a>
12+
<a href="Functor_ml.html">Functor_ml</a> &#x00BB; Bar
13+
</nav>
14+
<header class="odoc-preamble">
15+
<h1>Module <code><span>Functor_ml.Bar</span></code></h1>
16+
</header>
17+
<div class="odoc-content">
18+
<div class="odoc-spec">
19+
<div class="spec type anchored" id="type-t">
20+
<a href="#type-t" class="anchor"></a>
21+
<code><span><span class="keyword">type</span> t</span></code>
22+
</div>
23+
</div>
24+
</div>
25+
</body>
26+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head><title>X (Functor_ml.Foo'.X)</title>
4+
<link rel="stylesheet" href="odoc.css"/><meta charset="utf-8"/>
5+
<meta name="generator" content="odoc %%VERSION%%"/>
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
7+
<script src="highlight.pack.js"></script>
8+
<script>hljs.initHighlightingOnLoad();</script>
9+
</head>
10+
<body class="odoc">
11+
<nav class="odoc-nav"><a href="Functor_ml-Foo'.html">Up</a>
12+
<a href="Functor_ml.html">Functor_ml</a> &#x00BB;
13+
<a href="Functor_ml-Foo'.html">Foo'</a> &#x00BB; X
14+
</nav>
15+
<header class="odoc-preamble">
16+
<h1>Parameter <code><span>Foo'.X</span></code></h1>
17+
</header>
18+
<div class="odoc-content">
19+
<div class="odoc-spec">
20+
<div class="spec value anchored" id="val-foo">
21+
<a href="#val-foo" class="anchor"></a>
22+
<code><span><span class="keyword">val</span> foo : int</span></code>
23+
</div>
24+
</div>
25+
</div>
26+
</body>
27+
</html>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head><title>Foo' (Functor_ml.Foo')</title>
4+
<link rel="stylesheet" href="odoc.css"/><meta charset="utf-8"/>
5+
<meta name="generator" content="odoc %%VERSION%%"/>
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
7+
<script src="highlight.pack.js"></script>
8+
<script>hljs.initHighlightingOnLoad();</script>
9+
</head>
10+
<body class="odoc">
11+
<nav class="odoc-nav"><a href="Functor_ml.html">Up</a>
12+
<a href="Functor_ml.html">Functor_ml</a> &#x00BB; Foo'
13+
</nav>
14+
<header class="odoc-preamble">
15+
<h1>Module <code><span>Functor_ml.Foo'</span></code></h1>
16+
</header>
17+
<nav class="odoc-toc">
18+
<ul><li><a href="#parameters">Parameters</a></li>
19+
<li><a href="#signature">Signature</a></li>
20+
</ul>
21+
</nav>
22+
<div class="odoc-content">
23+
<h2 id="parameters"><a href="#parameters" class="anchor"></a>Parameters
24+
</h2>
25+
<div class="odoc-spec">
26+
<div class="spec parameter anchored" id="argument-1-X">
27+
<a href="#argument-1-X" class="anchor"></a>
28+
<code><span><span class="keyword">module</span> </span>
29+
<span><a href="Functor_ml-Foo'-argument-1-X.html">X</a></span>
30+
<span> : <span class="keyword">sig</span> ...
31+
<span class="keyword">end</span>
32+
</span>
33+
</code>
34+
</div>
35+
</div>
36+
<h2 id="signature"><a href="#signature" class="anchor"></a>Signature</h2>
37+
<div class="odoc-spec">
38+
<div class="spec type anchored" id="type-t">
39+
<a href="#type-t" class="anchor"></a>
40+
<code><span><span class="keyword">type</span> t</span>
41+
<span> = <a href="Functor_ml-Bar.html#type-t">Bar.t</a></span>
42+
</code>
43+
</div>
44+
</div>
45+
</div>
46+
</body>
47+
</html>

test/generators/html/Functor_ml.html

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head><title>Functor_ml (Functor_ml)</title>
4+
<link rel="stylesheet" href="odoc.css"/><meta charset="utf-8"/>
5+
<meta name="generator" content="odoc %%VERSION%%"/>
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
7+
<script src="highlight.pack.js"></script>
8+
<script>hljs.initHighlightingOnLoad();</script>
9+
</head>
10+
<body class="odoc">
11+
<header class="odoc-preamble">
12+
<h1>Module <code><span>Functor_ml</span></code></h1>
13+
</header>
14+
<div class="odoc-content">
15+
<div class="odoc-spec">
16+
<div class="spec module anchored" id="module-Foo">
17+
<a href="#module-Foo" class="anchor"></a>
18+
<code><span><span class="keyword">module</span> Foo</span>
19+
<span> (<a href="Functor_ml-Foo-argument-1-X.html">X</a> :
20+
<span class="keyword">sig</span> ... <span class="keyword">end</span>
21+
) : <span class="keyword">module</span>
22+
<span class="keyword">type</span> <span class="keyword">of</span>
23+
<span class="xref-unresolved">Stdlib</span>.String
24+
</span>
25+
</code>
26+
</div>
27+
</div>
28+
<div class="odoc-spec">
29+
<div class="spec module anchored" id="module-Bar">
30+
<a href="#module-Bar" class="anchor"></a>
31+
<code>
32+
<span><span class="keyword">module</span>
33+
<a href="Functor_ml-Bar.html">Bar</a>
34+
</span>
35+
<span> : <span class="keyword">sig</span> ...
36+
<span class="keyword">end</span>
37+
</span>
38+
</code>
39+
</div>
40+
</div>
41+
<div class="odoc-spec">
42+
<div class="spec module anchored" id="module-Foo'">
43+
<a href="#module-Foo'" class="anchor"></a>
44+
<code>
45+
<span><span class="keyword">module</span>
46+
<a href="Functor_ml-Foo'.html">Foo'</a>
47+
</span>
48+
<span> (<a href="Functor_ml-Foo'-argument-1-X.html">X</a> :
49+
<span class="keyword">sig</span> ... <span class="keyword">end</span>
50+
) : <span class="keyword">sig</span> ...
51+
<span class="keyword">end</span>
52+
</span>
53+
</code>
54+
</div>
55+
</div>
56+
</div>
57+
</body>
58+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Functor_ml.html
2+
Functor_ml-Bar.html
3+
Functor_ml-Foo'.html
4+
Functor_ml-Foo'-argument-1-X.html
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
\section{Module \ocamlinlinecode{Functor\_\allowbreak{}ml.\allowbreak{}Foo'}}\label{module-Functor_ml-module-Foo'}%
2+
\subsection{Parameters\label{parameters}}%
3+
\label{module-Functor_ml-module-Foo'-argument-1-X}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor_ml-module-Foo'-argument-1-X]{\ocamlinlinecode{X}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor_ml-module-Foo'-argument-1-X-val-foo}\ocamlcodefragment{\ocamltag{keyword}{val} foo : int}\\
4+
\end{ocamlindent}%
5+
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
6+
\subsection{Signature\label{signature}}%
7+
\label{module-Functor_ml-module-Foo'-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Functor_ml-module-Bar-type-t]{\ocamlinlinecode{Bar.\allowbreak{}t}}}\\
8+
9+

test/generators/latex/Functor_ml.tex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
\section{Module \ocamlinlinecode{Functor\_\allowbreak{}ml}}\label{module-Functor_ml}%
2+
\label{module-Functor_ml-module-Foo}\ocamlcodefragment{\ocamltag{keyword}{module} Foo (\hyperref[module-Functor_ml-module-Foo-argument-1-X]{\ocamlinlinecode{X}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \hyperref[xref-unresolved]{\ocamlinlinecode{Stdlib}}.\allowbreak{}String}\\
3+
\label{module-Functor_ml-module-Bar}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor_ml-module-Bar]{\ocamlinlinecode{Bar}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor_ml-module-Bar-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\
4+
\end{ocamlindent}%
5+
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
6+
\label{module-Functor_ml-module-Foo'}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor_ml-module-Foo']{\ocamlinlinecode{Foo'}}}\ocamlcodefragment{ (\hyperref[module-Functor_ml-module-Foo'-argument-1-X]{\ocamlinlinecode{X}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\
7+
8+
\input{Functor_ml.Foo'.tex}

0 commit comments

Comments
 (0)