From 62d037874077830fdde27bd3723d2a3015c5cb5d Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Mon, 9 Mar 2015 23:32:25 -0700 Subject: [PATCH] Fix #82 --- src/dfmt.d | 13 ++++++++----- tests/issue0082.d | 12 ++++++++++++ tests/issue0082.d.ref | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 tests/issue0082.d create mode 100644 tests/issue0082.d.ref diff --git a/src/dfmt.d b/src/dfmt.d index 53f0ade..6c6dabf 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -580,7 +580,8 @@ private: write(" "); break; default: - assert (false, str(current.type)); + writeToken(); + break; } } else if (currentIs(tok!"identifier")) @@ -594,7 +595,7 @@ private: } } else - assert (false, str(current.type)); + writeToken(); } void regenLineBreakHintsIfNecessary(immutable size_t i) @@ -914,9 +915,11 @@ private: } } indentLevel = l; - assert (currentIs(tok!"}")); - writeToken(); - newline(); + if (currentIs(tok!"}")) + { + writeToken(); + newline(); + } } int currentTokenLength() pure @safe @nogc diff --git a/tests/issue0082.d b/tests/issue0082.d new file mode 100644 index 0000000..6a887e4 --- /dev/null +++ b/tests/issue0082.d @@ -0,0 +1,12 @@ +unittest +{ +label: +if (x) +{ +} +Label: + + // comment + statement(); + } +} diff --git a/tests/issue0082.d.ref b/tests/issue0082.d.ref new file mode 100644 index 0000000..9a13ad9 --- /dev/null +++ b/tests/issue0082.d.ref @@ -0,0 +1,14 @@ +unittest +{ +label: + if (x) + { + } +Label: + + + + // comment + statement(); +} +} \ No newline at end of file