diff options
author | LemonBoy <thatlemon@gmail.com> | 2018-09-19 21:17:48 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2018-09-21 18:59:46 +0200 |
commit | 4d9aec1858ecd8651276a5e1d6ca939d345b4d11 (patch) | |
tree | 1130641e6c7fd2b60680df3ac8e1415fb928f7dd | |
parent | 0951b5b73677f610fd0eb8c274fc540349138d9c (diff) | |
download | Nim-4d9aec1858ecd8651276a5e1d6ca939d345b4d11.tar.gz |
Revert #7964
Somehow the test case doesn't crash anymore and the regression in the doc generation is fixed. Fixes #9019
-rw-r--r-- | compiler/semstmts.nim | 8 | ||||
-rw-r--r-- | compiler/transf.nim | 11 | ||||
-rw-r--r-- | nimdoc/testproject/expected/testproject.html | 18 | ||||
-rw-r--r-- | nimdoc/testproject/expected/theindex.html | 6 | ||||
-rw-r--r-- | nimdoc/testproject/testproject.nim | 2 | ||||
-rw-r--r-- | tests/let/t7936.nim | 27 |
6 files changed, 59 insertions, 13 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 87d144dc6..75a4198a5 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -495,12 +495,8 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = # keep documentation information: b.comment = a.comment addSon(b, newSymNode(v)) - # keep type desc for doc generator, but only if the user explicitly - # added it - if a.sons[length-2].kind != nkEmpty: - addSon(b, newNodeIT(nkType, a.info, typ)) - else: - addSon(b, a.sons[length-2]) + # keep type desc for doc generator + addSon(b, a.sons[length-2]) addSon(b, copyTree(def)) addToVarSection(c, result, n, b) else: diff --git a/compiler/transf.nim b/compiler/transf.nim index 0c3ddf27a..b31be71a3 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -935,12 +935,11 @@ proc transform(c: PTransf, n: PNode): PTransNode = else: result = transformSons(c, n) of nkIdentDefs, nkConstDef: - when true: - result = transformSons(c, n) - else: - result = n.PTransNode - let L = n.len-1 - result[L] = transform(c, n.sons[L]) + result = PTransNode(n) + result[0] = transform(c, n[0]) + # Skip the second son since it only contains an unsemanticized copy of the + # variable type used by docgen + result[2] = transform(c, n[2]) # XXX comment handling really sucks: if importantComments(c.graph.config): PNode(result).comment = n.comment diff --git a/nimdoc/testproject/expected/testproject.html b/nimdoc/testproject/expected/testproject.html index 784fbe9b7..064a70011 100644 --- a/nimdoc/testproject/expected/testproject.html +++ b/nimdoc/testproject/expected/testproject.html @@ -1245,6 +1245,14 @@ function main() { </ul> </li> <li> + <a class="reference reference-toplevel" href="#8" id="58">Vars</a> + <ul class="simple simple-toc-section"> + <li><a class="reference" href="#aVariable" + title="aVariable: array[1, int]"><wbr />a<wbr />Variable<span class="attachedType" style="visibility:hidden"></span></a></li> + + </ul> +</li> +<li> <a class="reference reference-toplevel" href="#12" id="62">Procs</a> <ul class="simple simple-toc-section"> <li><a class="reference" href="#bar,T,T" @@ -1286,6 +1294,16 @@ function main() { <dl class="item"> <a class="reference external" href="subdir/subdir_b/utils.html">subdir/subdir_b/utils</a> </dl></div> +<div class="section" id="8"> +<h1><a class="toc-backref" href="#8">Vars</a></h1> +<dl class="item"> +<dt id="aVariable"><a name="aVariable"></a><pre><span class="Identifier">aVariable</span><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt> +<dd> + + +</dd> + +</dl></div> <div class="section" id="12"> <h1><a class="toc-backref" href="#12">Procs</a></h1> <dl class="item"> diff --git a/nimdoc/testproject/expected/theindex.html b/nimdoc/testproject/expected/theindex.html index 7e4f8d397..fc5c0e1c5 100644 --- a/nimdoc/testproject/expected/theindex.html +++ b/nimdoc/testproject/expected/theindex.html @@ -1221,7 +1221,11 @@ function main() { <div class="container"> <h1 class="title">Index</h1> Modules: <a href="subdir/subdir_b/utils.html">subdir/subdir_b/utils</a>, <a href="testproject.html">testproject</a>.<br/><p /><h2>API symbols</h2> -<dl><dt><a name="bar" href="#bar"><span>bar:</span></a></dt><dd><ul class="simple"> +<dl><dt><a name="aVariable" href="#aVariable"><span>aVariable:</span></a></dt><dd><ul class="simple"> +<li><a class="reference external" + data-doc-search-tag="testproject: aVariable" href="testproject.html#aVariable">testproject: aVariable</a></li> + </ul></dd> +<dt><a name="bar" href="#bar"><span>bar:</span></a></dt><dd><ul class="simple"> <li><a class="reference external" data-doc-search-tag="testproject: bar[T](a, b: T): T" href="testproject.html#bar,T,T">testproject: bar[T](a, b: T): T</a></li> <li><a class="reference external" diff --git a/nimdoc/testproject/testproject.nim b/nimdoc/testproject/testproject.nim index b4f6a58fb..327466014 100644 --- a/nimdoc/testproject/testproject.nim +++ b/nimdoc/testproject/testproject.nim @@ -20,3 +20,5 @@ import std/macros macro bar*(): untyped = result = newStmtList() + +var aVariable*: array[1,int] diff --git a/tests/let/t7936.nim b/tests/let/t7936.nim new file mode 100644 index 000000000..3819dfc02 --- /dev/null +++ b/tests/let/t7936.nim @@ -0,0 +1,27 @@ +discard """ + action: "run" +""" + +import + tables, deques, sequtils + +const + lookupTable = {'(': ')', '{': '}', '[': ']'}.toTable + +proc isPaired*(value: string): bool = + var stack = initDeque[char]() + + for item in value: + # echo "Looking at " & item + if item in lookupTable: + stack.addLast(item) + if item in toSeq(lookupTable.values): + if stack.len == 0: + return false + if lookupTable[stack.popLast()] != item: + return false + + return stack.len == 0 + +doAssert isPaired("{[()]}") == true +doAssert isPaired("a)b(c") == false |