fixes #15688; handle strongSpace overflow issues (#20724)

* fixes #15688; handle `strongSpace` overflow issues

* stop at 1

* change the type of strongSpaceA to bool
This commit is contained in:
ringabout 2022-11-03 16:18:09 +08:00 • committed by GitHub
commit 0b1d1b7886
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 20 deletions

View file

@ -267,7 +267,7 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
if not em.endsInWhite: wr(" ")
wr(tok.ident.s)
template isUnary(tok): bool =
tok.strongSpaceB == 0 and tok.strongSpaceA > 0
tok.strongSpaceB == 0 and tok.strongSpaceA
if not isUnary(tok) or em.lastTok in {tkOpr, tkDotDot}:
wr(" ")

View file

@ -272,7 +272,7 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
if not em.endsInWhite: wr(" ")
wr(tok.ident.s)
template isUnary(tok): bool =
tok.strongSpaceB == 0 and tok.strongSpaceA > 0
tok.strongSpaceB == 0 and tok.strongSpaceA
if not isUnary(tok) or em.lastTok in {tkOpr, tkDotDot}:
wr(" ")