From 7659b1ae1aaaeda6b787ec60a2ed1e902326d5a0 Mon Sep 17 00:00:00 2001 From: Brian Schott Date: Wed, 30 Sep 2020 23:35:20 -0700 Subject: [PATCH] Fix Issue 508 (#511) Fix Issue 508 merged-on-behalf-of: Brian Schott --- src/dfmt/formatter.d | 3 ++- tests/allman/issue0508.d.ref | 7 +++++++ tests/issue0508.d | 1 + tests/otbs/issue0508.d.ref | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/allman/issue0508.d.ref create mode 100644 tests/issue0508.d create mode 100644 tests/otbs/issue0508.d.ref diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 2d03b54..12bd8fe 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -9,8 +9,8 @@ module dfmt.formatter; import dparse.lexer; import dparse.parser; import dparse.rollback_allocator; -import dfmt.config; import dfmt.ast_info; +import dfmt.config; import dfmt.indentation; import dfmt.tokens; import dfmt.wrapping; @@ -765,6 +765,7 @@ private: } else if (hasCurrent && (currentIs(tok!"@") || isBasicType(tokens[index].type) + || currentIs(tok!"invariant") || currentIs(tok!"extern") || currentIs(tok!"identifier")) && !currentIsIndentedTemplateConstraint()) diff --git a/tests/allman/issue0508.d.ref b/tests/allman/issue0508.d.ref new file mode 100644 index 0000000..af4c328 --- /dev/null +++ b/tests/allman/issue0508.d.ref @@ -0,0 +1,7 @@ +struct S +{ + @safe invariant + { + assert(true); + } +} diff --git a/tests/issue0508.d b/tests/issue0508.d new file mode 100644 index 0000000..d6f1f3d --- /dev/null +++ b/tests/issue0508.d @@ -0,0 +1 @@ +struct S {@safe invariant { assert(true); }} diff --git a/tests/otbs/issue0508.d.ref b/tests/otbs/issue0508.d.ref new file mode 100644 index 0000000..acd5850 --- /dev/null +++ b/tests/otbs/issue0508.d.ref @@ -0,0 +1,5 @@ +struct S { + @safe invariant { + assert(true); + } +}