[bugfix] nimpretty: fixes #11470
This commit is contained in:
parent
af39f26a3a
commit
165ea46284
3 changed files with 33 additions and 3 deletions
|
|
@ -346,7 +346,7 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
|
||||||
if endsInAlpha(em):
|
if endsInAlpha(em):
|
||||||
wrSpace em
|
wrSpace em
|
||||||
elif not em.inquote and not endsInWhite(em) and
|
elif not em.inquote and not endsInWhite(em) and
|
||||||
em.lastTok notin openPars and not em.lastTokWasTerse:
|
em.lastTok notin (openPars+{tkOpr, tkDotDot}) and not em.lastTokWasTerse:
|
||||||
#and tok.tokType in oprSet
|
#and tok.tokType in oprSet
|
||||||
wrSpace em
|
wrSpace em
|
||||||
|
|
||||||
|
|
@ -392,8 +392,8 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
|
||||||
wr(em, TokTypeToStr[tok.tokType], ltOther)
|
wr(em, TokTypeToStr[tok.tokType], ltOther)
|
||||||
if not em.inquote: wrSpace(em)
|
if not em.inquote: wrSpace(em)
|
||||||
of tkOpr, tkDotDot:
|
of tkOpr, tkDotDot:
|
||||||
if ((tok.strongSpaceA == 0 and tok.strongSpaceB == 0) or em.inquote) and
|
if em.inquote or ((tok.strongSpaceA == 0 and tok.strongSpaceB == 0) and
|
||||||
tok.ident.s notin ["<", ">", "<=", ">=", "==", "!="]:
|
tok.ident.s notin ["<", ">", "<=", ">=", "==", "!="]):
|
||||||
# bug #9504: remember to not spacify a keyword:
|
# bug #9504: remember to not spacify a keyword:
|
||||||
lastTokWasTerse = true
|
lastTokWasTerse = true
|
||||||
# if not surrounded by whitespace, don't produce any whitespace either:
|
# if not surrounded by whitespace, don't produce any whitespace either:
|
||||||
|
|
|
||||||
|
|
@ -417,3 +417,18 @@ proc isValid1*[A](s: HashSet[A]): bool {.deprecated:
|
||||||
## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
|
## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
|
||||||
result = s.data.len > 0
|
result = s.data.len > 0
|
||||||
# bug #11468
|
# bug #11468
|
||||||
|
|
||||||
|
assert $type(a) == "Option[system.int]"
|
||||||
|
foo(a, $type(b), c)
|
||||||
|
foo(type(b), c) # this is ok
|
||||||
|
|
||||||
|
proc `<`*[A](s, t: A): bool = discard
|
||||||
|
proc `==`*[A](s, t: HashSet[A]): bool = discard
|
||||||
|
proc `<=`*[A](s, t: HashSet[A]): bool = discard
|
||||||
|
|
||||||
|
# these are ok:
|
||||||
|
proc `$`*[A](s: HashSet[A]): string = discard
|
||||||
|
proc `*`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} = discard
|
||||||
|
proc `-+-`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} = discard
|
||||||
|
|
||||||
|
# bug #11470
|
||||||
|
|
|
||||||
|
|
@ -427,3 +427,18 @@ proc isValid1*[A](s: HashSet[A]): bool {.deprecated:
|
||||||
## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
|
## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
|
||||||
result = s.data.len > 0
|
result = s.data.len > 0
|
||||||
# bug #11468
|
# bug #11468
|
||||||
|
|
||||||
|
assert $type(a) == "Option[system.int]"
|
||||||
|
foo(a, $type(b), c)
|
||||||
|
foo(type(b), c) # this is ok
|
||||||
|
|
||||||
|
proc `<`*[A](s, t: A): bool = discard
|
||||||
|
proc `==`*[A](s, t: HashSet[A]): bool = discard
|
||||||
|
proc `<=`*[A](s, t: HashSet[A]): bool = discard
|
||||||
|
|
||||||
|
# these are ok:
|
||||||
|
proc `$`*[A](s: HashSet[A]): string = discard
|
||||||
|
proc `*`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} = discard
|
||||||
|
proc `-+-`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} = discard
|
||||||
|
|
||||||
|
# bug #11470
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue