diff --git a/README.md b/README.md index e25dd30..6c3d766 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ found there. * `--soft_max_line_length`: *see dfmt_soft_max_line_length [below](#dfmt-specific-properties)* * `--space_after_cast`: *see dfmt_space_after_cast [below](#dfmt-specific-properties)* * `--space_before_aa_colon`: *see dfmt_space_before_aa_colon [below](#dfmt-specific-properties)* +* `--space_before_named_arg_colon`: *see dfmt_space_before_named_arg_colon [below](#dfmt-specific-properties)* * `--space_before_function_parameters`: *see dfmt_space_before_function_parameters [below](#dfmt-specific-properties)* * `--split_operator_at_line_end`: *see dfmt_split_operator_at_line_end [below](#dfmt-specific-properties)* * `--tab_width`: *see tab_width [below](#standard-editorconfig-properties)* @@ -59,6 +60,7 @@ found there. * `--keep_line_breaks`: *see dfmt_keep_line_breaks [below](#dfmt-specific-properties)* * `--single_indent`: *see dfmt_single_indent [below](#dfmt-specific-properties)* * `--reflow_property_chains`: *see dfmt_property_chains [below](#dfmt-specific-properties)* +* `--space_after_keywords`: *see dfmt_space_after_keywords [below](#dfmt-specific-properties)* ### Example ``` @@ -118,9 +120,11 @@ dfmt_compact_labeled_statements | **`true`**, `false` | Place labels on the same dfmt_template_constraint_style | **`conditional_newline_indent`** `conditional_newline` `always_newline` `always_newline_indent` | Control the formatting of template constraints. dfmt_single_template_constraint_indent | `true`, **`false`** | Set if the constraints are indented by a single tab instead of two. Has only an effect if the style set to `always_newline_indent` or `conditional_newline_indent`. dfmt_space_before_aa_colon | `true`, **`false`** | Adds a space after an associative array key before the `:` like in older dfmt versions. +dfmt_space_before_named_arg_colon | `true`, **`false`** | Adds a space after a named function argument or named struct constructor argument before the `:`. dfmt_keep_line_breaks | `true`, **`false`** | Keep existing line breaks if these don't violate other formatting rules. dfmt_single_indent | `true`, **`false`** | Set if the code in parens is indented by a single tab instead of two. dfmt_reflow_property_chains | **`true`**, `false` | Recalculate the splitting of property chains into multiple lines. +dfmt_space_after_keywords | **`true`**, `false` | Insert space after keywords (if,while,foreach,for, etc.). ## Terminology * Braces - `{` and `}` diff --git a/makefile b/makefile index d790c0c..74db7b5 100644 --- a/makefile +++ b/makefile @@ -1,53 +1,63 @@ +PREFIX = /usr/local + SRC := $(shell find src -name "*.d") \ - $(shell find libdparse/src -name "*.d") \ - $(shell find stdx-allocator/source -name "*.d") -INCLUDE_PATHS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Jbin -DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS) -DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS) -DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS) -DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS) -LDC_FLAGS := -g -w -oq $(INCLUDE_PATHS) -GDC_FLAGS := -g -w -oq $(INCLUDE_PATHS) -override DMD_FLAGS += $(DFLAGS) -override LDC_FLAGS += $(DFLAGS) -override GDC_FLAGS += $(DFLAGS) + $(shell find libdparse/src -name "*.d") +IMPORTS := -Ilibdparse/src -Isrc -Jbin + DC ?= dmd LDC ?= ldc2 GDC ?= gdc -.PHONY: dmd ldc gdc test +DMD_COMMON_FLAGS := -w $(IMPORTS) +DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS) +DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS) +DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS) +LDC_FLAGS := -g -w -oq $(IMPORTS) +GDC_FLAGS := -g -w -oq $(IMPORTS) +override DMD_FLAGS += $(DFLAGS) +override LDC_FLAGS += $(DFLAGS) +override GDC_FLAGS += $(DFLAGS) -dmd: bin/dfmt +.PHONY: all clean install debug dmd ldc gdc pkg release test -githash: +all: bin/dfmt + +bin/githash.txt: mkdir -p bin git describe --tags > bin/githash.txt -ldc: githash +dmd: bin/dfmt + +ldc: bin/githash.txt $(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt -rm -f *.o -gdc:githash +gdc: bin/githash.txt $(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt test: debug cd tests && ./test.d -bin/dfmt-test: githash $(SRC) - $(DC) $(DMD_TEST_FLAGS) $^ -of$@ +bin/dfmt-test: bin/githash.txt $(SRC) + $(DC) $(DMD_TEST_FLAGS) $(filter %.d,$^) -of$@ -bin/dfmt: githash $(SRC) +bin/dfmt: bin/githash.txt $(SRC) $(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@ -debug: githash $(SRC) +debug: bin/githash.txt $(SRC) $(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt pkg: dmd $(MAKE) -f makd/Makd.mak pkg clean: - $(RM) bin/dfmt + $(RM) bin/dfmt bin/dfmt-test bin/githash.txt + +install: + chmod +x bin/dfmt + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f bin/dfmt $(DESTDIR)$(PREFIX)/bin/dfmt release: ./release.sh - githash + $(MAKE) bin/githash.txt diff --git a/src/dfmt/ast_info.d b/src/dfmt/ast_info.d index 56030f1..34a8ede 100644 --- a/src/dfmt/ast_info.d +++ b/src/dfmt/ast_info.d @@ -63,6 +63,8 @@ struct ASTInformation (structInfoSortedByEndLocation); sort(ufcsHintLocations); ufcsHintLocations = ufcsHintLocations.uniq().array(); + sort(ternaryColonLocations); + sort(namedArgumentColonLocations); } /// Locations of end braces for struct bodies @@ -135,6 +137,12 @@ struct ASTInformation /// Opening & closing braces of struct initializers StructInitializerInfo[] structInfoSortedByEndLocation; + + /// Locations ternary expression colons. + size_t[] ternaryColonLocations; + + /// Locations of named arguments of function call or struct constructor. + size_t[] namedArgumentColonLocations; } /// Collects information from the AST that is useful for the formatter @@ -438,6 +446,43 @@ final class FormatVisitor : ASTVisitor outStatement.accept(this); } + override void visit(const TernaryExpression ternaryExpression) + { + astInformation.ternaryColonLocations ~= ternaryExpression.colon.index; + ternaryExpression.accept(this); + } + + override void visit(const FunctionCallExpression functionCall) + { + // Check if function has any arguments. + if (functionCall.arguments.namedArgumentList is null) + { + functionCall.accept(this); + return; + } + + foreach (item; functionCall.arguments.namedArgumentList.items) + { + // Do nothing if not a named argument. + if (item.name == tok!"") + { + continue; + } + + // Find first colon if named argument. + foreach (t; item.tokens) + { + if (t.type == tok!":") + { + astInformation.namedArgumentColonLocations ~= t.index; + break; + } + } + } + + functionCall.accept(this); + } + private: ASTInformation* astInformation; } diff --git a/src/dfmt/config.d b/src/dfmt/config.d index ce0fbd5..6b41d4a 100644 --- a/src/dfmt/config.d +++ b/src/dfmt/config.d @@ -65,6 +65,10 @@ struct Config OptionalBoolean dfmt_single_indent; /// OptionalBoolean dfmt_reflow_property_chains; + /// + OptionalBoolean dfmt_space_after_statement_keyword; + /// + OptionalBoolean dfmt_space_before_named_arg_colon; mixin StandardEditorConfigFields; @@ -96,6 +100,7 @@ struct Config dfmt_keep_line_breaks = OptionalBoolean.f; dfmt_single_indent = OptionalBoolean.f; dfmt_reflow_property_chains = OptionalBoolean.t; + dfmt_space_before_named_arg_colon = OptionalBoolean.f; } /** diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index f649ed3..0f7e821 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -257,7 +257,9 @@ private: if (indents.length == 0 || !indents.topIsOneOf(tok!"switch", tok!"with")) indents.push(tok!"with"); writeToken(); - write(" "); + if (config.dfmt_space_after_keywords) { + write(" "); + } if (hasCurrent && currentIs(tok!"(")) writeParens(false); if (hasCurrent && !currentIs(tok!"switch") && !currentIs(tok!"with") @@ -266,7 +268,9 @@ private: newline(); } else if (hasCurrent && !currentIs(tok!"{")) + { write(" "); + } } else if (currentIs(tok!"switch")) { @@ -831,12 +835,13 @@ private: { import dfmt.editorconfig : OptionalBoolean; import std.algorithm : canFind, any; - immutable bool isCase = astInformation.caseEndLocations.canFindIndex(current.index); immutable bool isAttribute = astInformation.attributeDeclarationLines.canFindIndex( current.line); immutable bool isStructInitializer = astInformation.structInfoSortedByEndLocation .canFind!(st => st.startLocation < current.index && current.index < st.endLocation); + immutable bool isTernary = astInformation.ternaryColonLocations.canFindIndex(current.index); + immutable bool isNamedArg = astInformation.namedArgumentColonLocations.canFindIndex(current.index); if (isCase || isAttribute) { @@ -852,11 +857,17 @@ private: newline(); } } - else if (indents.topIs(tok!"]")) // Associative array + else if (indents.topIs(tok!"]") && !isTernary) // Associative array { write(config.dfmt_space_before_aa_colon ? " : " : ": "); ++index; } + // Named function or struct constructor arguments. + else if (isNamedArg) + { + write(config.dfmt_space_before_named_arg_colon ? " : " : ": "); + ++index; + } else if (peekBackIs(tok!"identifier") && [tok!"{", tok!"}", tok!";", tok!":", tok!","] .any!((ptrdiff_t token) => peekBack2Is(cast(IdType)token, true)) @@ -1049,6 +1060,21 @@ private: if (niBraceDepth > 0) niBraceDepth--; + // Account for possible function literals in this array which offset + // the previously set index (pos). Fixes issue #432. + size_t newPos = pos; + while(astInformation.indentInfoSortedByEndLocation[newPos].endLocation < + tokens[index].index) + { + newPos++; + } + + if (astInformation.indentInfoSortedByEndLocation[newPos].endLocation == + tokens[index].index) + { + pos = newPos; + } + auto indentInfo = astInformation.indentInfoSortedByEndLocation[pos]; if (indentInfo.flags & BraceIndentInfoFlags.tempIndent) { @@ -1118,7 +1144,10 @@ private: indents.pop(); indents.push(tok!"switch"); writeToken(); // switch - write(" "); + if (config.dfmt_space_after_keywords) + { + write(" "); + } } void formatBlockHeader() @@ -1149,16 +1178,26 @@ private: if (currentIs(tok!"(")) { - write(" "); + if (config.dfmt_space_after_keywords) + { + write(" "); + } writeParens(false); } if (hasCurrent) { if (currentIs(tok!"switch") || (currentIs(tok!"final") && peekIs(tok!"switch"))) - write(" "); + { + if (config.dfmt_space_after_keywords) + { + write(" "); + } + } else if (currentIs(tok!"comment")) + { formatStep(); + } else if (!shouldPushIndent) { if (!currentIs(tok!"{") && !currentIs(tok!";")) diff --git a/src/dfmt/globmatch_editorconfig.d b/src/dfmt/globmatch_editorconfig.d index eff1b79..576915c 100644 --- a/src/dfmt/globmatch_editorconfig.d +++ b/src/dfmt/globmatch_editorconfig.d @@ -12,7 +12,7 @@ import std.path : filenameCharCmp, isDirSeparator; // * changes meaning to match all characters except '/' // ** added to take over the old meaning of * bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)( - Range path, const(C)[] pattern) @safe pure nothrow + Range path, const(C)[] pattern) @safe pure if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range))) in diff --git a/src/dfmt/main.d b/src/dfmt/main.d index a332a93..c5a5577 100644 --- a/src/dfmt/main.d +++ b/src/dfmt/main.d @@ -92,6 +92,9 @@ else case "space_before_aa_colon": optConfig.dfmt_space_before_aa_colon = optVal; break; + case "space_before_named_arg_colon": + optConfig.dfmt_space_before_named_arg_colon = optVal; + break; case "keep_line_breaks": optConfig.dfmt_keep_line_breaks = optVal; break; @@ -101,6 +104,9 @@ else case "reflow_property_chains": optConfig.dfmt_reflow_property_chains = optVal; break; + case "space_after_keywords": + optConfig.dfmt_space_after_keywords = optVal; + break; default: assert(false, "Invalid command-line switch"); } @@ -123,12 +129,14 @@ else "soft_max_line_length", &optConfig.dfmt_soft_max_line_length, "outdent_attributes", &handleBooleans, "space_after_cast", &handleBooleans, + "space_after_keywords", &handleBooleans, "selective_import_space", &handleBooleans, "space_before_function_parameters", &handleBooleans, "split_operator_at_line_end", &handleBooleans, "compact_labeled_statements", &handleBooleans, "single_template_constraint_indent", &handleBooleans, "space_before_aa_colon", &handleBooleans, + "space_before_named_arg_colon", &handleBooleans, "tab_width", &optConfig.tab_width, "template_constraint_style", &optConfig.dfmt_template_constraint_style, "keep_line_breaks", &handleBooleans, @@ -338,12 +346,14 @@ Formatting Options: --outdent_attributes --space_after_cast --space_before_function_parameters + --space_after_keywords --selective_import_space --single_template_constraint_indent --split_operator_at_line_end --compact_labeled_statements --template_constraint_style --space_before_aa_colon + --space_before_named_arg_colon --single_indent --reflow_property_chains `, diff --git a/tests/allman/issue0432.d.ref b/tests/allman/issue0432.d.ref new file mode 100644 index 0000000..9edb2d9 --- /dev/null +++ b/tests/allman/issue0432.d.ref @@ -0,0 +1,40 @@ +struct S1 +{ + ulong x; + ulong y; + ulong function(ulong) f; +} + +struct S2 +{ + ulong x; + ulong y; + ulong z; + ulong w; +} + +// ----------------------------------------------------------------------------- +// Example 1 +// Anonymous function in struct, long struct initializer + +immutable S1 s1 = { + 1111111111111111111, 1111111111111111111, (x) { return x + 1111; }, +}; + +void f1() +{ +} + +// ----------------------------------------------------------------------------- +// Example 2 +// Anonymous function anywhere, long struct initializer + +int function(int) f2 = (x) { return x + 1111; }; + +immutable S2 s = { + 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, +}; + +void f2() +{ +} diff --git a/tests/allman/issue0578.d.ref b/tests/allman/issue0578.d.ref new file mode 100644 index 0000000..74fd32b --- /dev/null +++ b/tests/allman/issue0578.d.ref @@ -0,0 +1,8 @@ +void f() +{ + auto t = true ? 1 : 0; + auto a = [true ? 1 : 0]; + auto aa1 = [0: true ? 1 : 0]; + auto aa2 = [0: true ? (false ? 1 : 2) : 3]; + auto aa3 = [0: true ? false ? 1 : 2 : 3]; +} diff --git a/tests/allman/issue0586.d.ref b/tests/allman/issue0586.d.ref new file mode 100644 index 0000000..cd86519 --- /dev/null +++ b/tests/allman/issue0586.d.ref @@ -0,0 +1,28 @@ +void temp(int v1, int v2) +{ +} + +int f(int i) +{ + return i; +} + +struct S +{ + int i; + int j; +} + +void main() +{ + temp(v1: 1, v2: 2); + temp(v1: 1, v2: 2,); + + auto s = S(5, j: 3); + + temp(v1: 1, v2: f(i: 2)); + + temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4); + + temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1); +} diff --git a/tests/allman/space_after_keywords.d.ref b/tests/allman/space_after_keywords.d.ref new file mode 100644 index 0000000..6d5b97b --- /dev/null +++ b/tests/allman/space_after_keywords.d.ref @@ -0,0 +1,15 @@ +void main(string[] args) +{ + for(int i = 0; i < 10; ++i) + { + if(i == 9) + break; + } + while(false) + { + } + + foreach(i; 0 .. 9) + { + } +} diff --git a/tests/issue0432.d b/tests/issue0432.d new file mode 100644 index 0000000..bbaa2bb --- /dev/null +++ b/tests/issue0432.d @@ -0,0 +1,38 @@ +struct S1 +{ + ulong x; + ulong y; + ulong function(ulong)f; +} + +struct S2 +{ + ulong x; + ulong y; + ulong z; + ulong w; +} + +// ----------------------------------------------------------------------------- +// Example 1 +// Anonymous function in struct, long struct initializer + +immutable S1 s1 = { + 1111111111111111111, 1111111111111111111, (x) { return x + 1111; },}; + + void f1() + { + } + +// ----------------------------------------------------------------------------- +// Example 2 +// Anonymous function anywhere, long struct initializer + +int function(int) f2 = (x) { return x + 1111; }; + +immutable S2 s = { + 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,}; + + void f2() + { + } diff --git a/tests/issue0578.d b/tests/issue0578.d new file mode 100644 index 0000000..6e6ea21 --- /dev/null +++ b/tests/issue0578.d @@ -0,0 +1,8 @@ +void f() +{ + auto t = true ? 1 : 0; + auto a = [true ? 1: 0]; + auto aa1 = [0: true ? 1: 0]; + auto aa2 = [0: true ? (false ? 1: 2): 3]; + auto aa3 = [0: true ? false ? 1: 2: 3]; +} diff --git a/tests/issue0586.d b/tests/issue0586.d new file mode 100644 index 0000000..db744f3 --- /dev/null +++ b/tests/issue0586.d @@ -0,0 +1,31 @@ +void temp(int v1, int v2) +{ +} + +int f(int i) +{ + return i; +} + +struct S +{ + int i; + int j; +} + +void main() +{ + temp(v1: 1, v2: 2); + temp( + v1: 1, + v2: 2, + ); + + auto s = S(5, j: 3); + + temp(v1: 1, v2: f(i: 2)); + + temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4); + + temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1); +} diff --git a/tests/knr/issue0432.d.ref b/tests/knr/issue0432.d.ref new file mode 100644 index 0000000..f403c86 --- /dev/null +++ b/tests/knr/issue0432.d.ref @@ -0,0 +1,38 @@ +struct S1 { + ulong x; + ulong y; + ulong function(ulong) f; +} + +struct S2 { + ulong x; + ulong y; + ulong z; + ulong w; +} + +// ----------------------------------------------------------------------------- +// Example 1 +// Anonymous function in struct, long struct initializer + +immutable S1 s1 = { + 1111111111111111111, 1111111111111111111, (x) { return x + 1111; }, +}; + +void f1() +{ +} + +// ----------------------------------------------------------------------------- +// Example 2 +// Anonymous function anywhere, long struct initializer + +int function(int) f2 = (x) { return x + 1111; }; + +immutable S2 s = { + 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, +}; + +void f2() +{ +} diff --git a/tests/knr/issue0578.d.ref b/tests/knr/issue0578.d.ref new file mode 100644 index 0000000..74fd32b --- /dev/null +++ b/tests/knr/issue0578.d.ref @@ -0,0 +1,8 @@ +void f() +{ + auto t = true ? 1 : 0; + auto a = [true ? 1 : 0]; + auto aa1 = [0: true ? 1 : 0]; + auto aa2 = [0: true ? (false ? 1 : 2) : 3]; + auto aa3 = [0: true ? false ? 1 : 2 : 3]; +} diff --git a/tests/knr/issue0586.d.ref b/tests/knr/issue0586.d.ref new file mode 100644 index 0000000..76c61bc --- /dev/null +++ b/tests/knr/issue0586.d.ref @@ -0,0 +1,27 @@ +void temp(int v1, int v2) +{ +} + +int f(int i) +{ + return i; +} + +struct S { + int i; + int j; +} + +void main() +{ + temp(v1: 1, v2: 2); + temp(v1: 1, v2: 2,); + + auto s = S(5, j: 3); + + temp(v1: 1, v2: f(i: 2)); + + temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4); + + temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1); +} diff --git a/tests/knr/space_after_keywords.d.ref b/tests/knr/space_after_keywords.d.ref new file mode 100644 index 0000000..a212bab --- /dev/null +++ b/tests/knr/space_after_keywords.d.ref @@ -0,0 +1,12 @@ +void main(string[] args) +{ + for(int i = 0; i < 10; ++i) { + if(i == 9) + break; + } + while(false) { + } + + foreach(i; 0 .. 9) { + } +} diff --git a/tests/otbs/issue0432.d.ref b/tests/otbs/issue0432.d.ref new file mode 100644 index 0000000..4690082 --- /dev/null +++ b/tests/otbs/issue0432.d.ref @@ -0,0 +1,36 @@ +struct S1 { + ulong x; + ulong y; + ulong function(ulong) f; +} + +struct S2 { + ulong x; + ulong y; + ulong z; + ulong w; +} + +// ----------------------------------------------------------------------------- +// Example 1 +// Anonymous function in struct, long struct initializer + +immutable S1 s1 = { + 1111111111111111111, 1111111111111111111, (x) { return x + 1111; }, +}; + +void f1() { +} + +// ----------------------------------------------------------------------------- +// Example 2 +// Anonymous function anywhere, long struct initializer + +int function(int) f2 = (x) { return x + 1111; }; + +immutable S2 s = { + 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, +}; + +void f2() { +} diff --git a/tests/otbs/issue0578.d.ref b/tests/otbs/issue0578.d.ref new file mode 100644 index 0000000..9f97fa7 --- /dev/null +++ b/tests/otbs/issue0578.d.ref @@ -0,0 +1,7 @@ +void f() { + auto t = true ? 1 : 0; + auto a = [true ? 1 : 0]; + auto aa1 = [0: true ? 1 : 0]; + auto aa2 = [0: true ? (false ? 1 : 2) : 3]; + auto aa3 = [0: true ? false ? 1 : 2 : 3]; +} diff --git a/tests/otbs/issue0586.d.ref b/tests/otbs/issue0586.d.ref new file mode 100644 index 0000000..e62ff1a --- /dev/null +++ b/tests/otbs/issue0586.d.ref @@ -0,0 +1,24 @@ +void temp(int v1, int v2) { +} + +int f(int i) { + return i; +} + +struct S { + int i; + int j; +} + +void main() { + temp(v1: 1, v2: 2); + temp(v1: 1, v2: 2,); + + auto s = S(5, j: 3); + + temp(v1: 1, v2: f(i: 2)); + + temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4); + + temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1); +} diff --git a/tests/otbs/space_after_keywords.d.ref b/tests/otbs/space_after_keywords.d.ref new file mode 100644 index 0000000..0a842e9 --- /dev/null +++ b/tests/otbs/space_after_keywords.d.ref @@ -0,0 +1,11 @@ +void main(string[] args) { + for(int i = 0; i < 10; ++i) { + if(i == 9) + break; + } + while(false) { + } + + foreach(i; 0 .. 9) { + } +} diff --git a/tests/space_after_keywords.args b/tests/space_after_keywords.args new file mode 100644 index 0000000..bdbb16c --- /dev/null +++ b/tests/space_after_keywords.args @@ -0,0 +1 @@ +--space_after_keywords=false diff --git a/tests/space_after_keywords.d b/tests/space_after_keywords.d new file mode 100644 index 0000000..34975ad --- /dev/null +++ b/tests/space_after_keywords.d @@ -0,0 +1,10 @@ +void main(string[] args) +{ + for (int i = 0; i < 10; ++i) { + if (i == 9) break; + } + while (false) {} + + foreach (i; 0 .. 9) { + } +}