[Issue 15317] New: Segfault in Type::kind() with DMD v2.069
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Nov 11 03:35:03 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15317
Issue ID: 15317
Summary: Segfault in Type::kind() with DMD v2.069
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: petar.p.kirov at gmail.com
I currently don't have time to reduce the issue, so I am posting the full
source code:
// Writes a numbered table of contents with in-page links of markdown file.
import std.stdio : File, writeln;
import std.file : readText;
import std.ascii : isAlphaNum, isWhite, toLower;
import std.algorithm : countUntil, each, filter, find, findSplit,
joiner, map, splitter, stripRight;
import std.array : replaceLast, replace;
import std.range : chain, drop, front, tee;
import std.string;
import std.conv : to;
void main()
{
enum indent = " ";
uint lastLvl = 1;
uint lvl = 1;
uint titleNum = 1;
File("markdown_test.md")
.byLine
.filter!(line => line.startsWith("#"))
.tee!((line)
{
auto currLvl = countUntil!(ch => ch.isAlphaNum)(line, "#");
titleNum = (currLvl == lastLvl)? titleNum + 1 : 1;
lastLvl = cast(uint)currLvl;
})
.map!(line => line.stripRight('#'))
.map!(line => line.replaceLast("#", titleNum.to!string ~ "."))
.map!(line =>
line.find(".").drop(1).front.isWhite?
line :
line.replace(".", ". "))
.map!(line => line.replace("#", indent))
.map!((line)
{
auto split = line.findSplit(". ");
auto escaped = split[2]
.filter!(ch => ch.isAlphaNum || ch.isWhite)
.map!(ch => ch.toLower)
.to!string
.strip
.splitter!(ch => ch.isWhite)
.joiner("-");
return chain(
split[0], split[1],
"[", split[2].strip, "]",
"(#", escaped, ")"
);
})
.each!(line => line.writeln);
}
--
More information about the Digitalmars-d-bugs
mailing list