This reverts commit 3f00a738db.
This commit is contained in:
parent
bf894ad3eb
commit
d4022ebe53
4 changed files with 5 additions and 49 deletions
|
|
@ -184,7 +184,7 @@ proc endsInNoReturn(n: PNode): bool =
|
||||||
var it = n
|
var it = n
|
||||||
while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0:
|
while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0:
|
||||||
it = it.lastSon
|
it = it.lastSon
|
||||||
result = it.kind in (nkLastBlockStmts-{nkReturnStmt}) or
|
result = it.kind in nkLastBlockStmts or
|
||||||
it.kind in nkCallKinds and it[0].kind == nkSym and sfNoReturn in it[0].sym.flags
|
it.kind in nkCallKinds and it[0].kind == nkSym and sfNoReturn in it[0].sym.flags
|
||||||
|
|
||||||
proc commonType*(x: PType, y: PNode): PType =
|
proc commonType*(x: PType, y: PNode): PType =
|
||||||
|
|
|
||||||
|
|
@ -502,7 +502,7 @@ weirdScopes()
|
||||||
# bug #14985
|
# bug #14985
|
||||||
proc getScope(): string =
|
proc getScope(): string =
|
||||||
if true:
|
if true:
|
||||||
"hi"
|
return "hi"
|
||||||
else:
|
else:
|
||||||
"else"
|
"else"
|
||||||
|
|
||||||
|
|
@ -512,14 +512,14 @@ proc getScope3(): string =
|
||||||
try:
|
try:
|
||||||
"try"
|
"try"
|
||||||
except:
|
except:
|
||||||
"except"
|
return "except"
|
||||||
|
|
||||||
echo getScope3()
|
echo getScope3()
|
||||||
|
|
||||||
proc getScope2(): string =
|
proc getScope2(): string =
|
||||||
case true
|
case true
|
||||||
of true:
|
of true:
|
||||||
"bye"
|
return "bye"
|
||||||
else:
|
else:
|
||||||
"else"
|
"else"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ func foo(input: string): int =
|
||||||
try:
|
try:
|
||||||
parseInt(input)
|
parseInt(input)
|
||||||
except:
|
except:
|
||||||
0
|
return
|
||||||
|
|
||||||
func foo2(b, input: string): int =
|
func foo2(b, input: string): int =
|
||||||
case b:
|
case b:
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
discard """
|
|
||||||
errormsg: "expression 'len(src) shl 1' is of type 'int' and has to be used (or discarded)"
|
|
||||||
line: 19
|
|
||||||
"""
|
|
||||||
|
|
||||||
# bug #15280
|
|
||||||
|
|
||||||
type
|
|
||||||
HexFlags* {.pure.} = enum
|
|
||||||
LowerCase, ## Produce lowercase hexadecimal characters
|
|
||||||
PadOdd, ## Pads odd strings
|
|
||||||
SkipSpaces, ## Skips all the whitespace characters inside of string
|
|
||||||
SkipPrefix ## Skips `0x` and `x` prefixes at the begining of string
|
|
||||||
|
|
||||||
|
|
||||||
proc bytesToHex*(src: openarray[byte], dst: var openarray[char],
|
|
||||||
flags: set[HexFlags]): int =
|
|
||||||
if len(dst) == 0:
|
|
||||||
(len(src) shl 1)
|
|
||||||
else:
|
|
||||||
var halflast = false
|
|
||||||
let dstlen = len(dst)
|
|
||||||
var srclen = len(src)
|
|
||||||
|
|
||||||
if dstlen < (srclen shl 1):
|
|
||||||
if (dstlen and 1) == 1:
|
|
||||||
srclen = (dstlen - 1) shr 1
|
|
||||||
halflast = true
|
|
||||||
else:
|
|
||||||
srclen = (dstlen shr 1)
|
|
||||||
|
|
||||||
let lowercase = (HexFlags.LowerCase in flags)
|
|
||||||
|
|
||||||
var k = 0
|
|
||||||
for i in 0 ..< srclen:
|
|
||||||
let x = int(src[i])
|
|
||||||
inc(k, 2)
|
|
||||||
|
|
||||||
if halflast:
|
|
||||||
let x = int(src[srclen])
|
|
||||||
inc(k)
|
|
||||||
|
|
||||||
return k
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue