From a990afcedcc4c7bd25008c9fa4fd3906b3716795 Mon Sep 17 00:00:00 2001 From: tofu <38903670+otofu-tofu@users.noreply.github.com> Date: Thu, 4 Apr 2019 12:58:54 +0000 Subject: [PATCH] fixes #10200 (#10950) * fixes #10200 * add rule for other comparison operators * add rule for '!=' * add test * fixed to pass the test --- compiler/layouter.nim | 3 ++- nimpretty/tests/exhaustive.nim | 6 ++++++ nimpretty/tests/expected/exhaustive.nim | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler/layouter.nim b/compiler/layouter.nim index 7b91b7bc46..6cb129fc1e 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -247,7 +247,8 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) = wr(TokTypeToStr[tok.tokType]) if not em.inquote: wr(" ") of tkOpr, tkDotDot: - if (tok.strongSpaceA == 0 and tok.strongSpaceB == 0) or em.inquote: + if ((tok.strongSpaceA == 0 and tok.strongSpaceB == 0) or em.inquote) and + tok.ident.s notin ["<", ">", "<=", ">=", "==", "!="]: # bug #9504: remember to not spacify a keyword: lastTokWasTerse = true # if not surrounded by whitespace, don't produce any whitespace either: diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim index 9a0f9a49bb..2903a59afa 100644 --- a/nimpretty/tests/exhaustive.nim +++ b/nimpretty/tests/exhaustive.nim @@ -360,3 +360,9 @@ foobar # bug #9673 discard `* `(1, 2) + +proc fun4() = + var a = "asdf" + var i = 0 + while i