diff options
author | Clyybber <darkmine956@gmail.com> | 2020-10-24 11:45:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-24 11:45:18 +0200 |
commit | d4022ebe53062a7e1be5fd55637a3cce39b93a12 (patch) | |
tree | d0e3aaa974054e48e3acd7954e44ed52d9f14ea2 | |
parent | bf894ad3ebdd393a13b0ff69f5c7a221270639a7 (diff) | |
download | Nim-d4022ebe53062a7e1be5fd55637a3cce39b93a12.tar.gz |
Revert "fixes #15280 [backport:1.2] (#15281)" (#15700)
This reverts commit 3f00a738dbc8319b4dd2b86bf5529c096f2dd243.
-rw-r--r-- | compiler/sem.nim | 2 | ||||
-rw-r--r-- | tests/arc/tmovebug.nim | 6 | ||||
-rw-r--r-- | tests/casestmt/tcasestmt.nim | 2 | ||||
-rw-r--r-- | tests/semreject/tmixing_return_and_exprs.nim | 44 |
4 files changed, 5 insertions, 49 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index bc6119460..705e1b72c 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -184,7 +184,7 @@ proc endsInNoReturn(n: PNode): bool = var it = n while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0: 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 proc commonType*(x: PType, y: PNode): PType = diff --git a/tests/arc/tmovebug.nim b/tests/arc/tmovebug.nim index c735ea1eb..3b7a7c5df 100644 --- a/tests/arc/tmovebug.nim +++ b/tests/arc/tmovebug.nim @@ -502,7 +502,7 @@ weirdScopes() # bug #14985 proc getScope(): string = if true: - "hi" + return "hi" else: "else" @@ -512,14 +512,14 @@ proc getScope3(): string = try: "try" except: - "except" + return "except" echo getScope3() proc getScope2(): string = case true of true: - "bye" + return "bye" else: "else" diff --git a/tests/casestmt/tcasestmt.nim b/tests/casestmt/tcasestmt.nim index 2151892aa..53cccdb64 100644 --- a/tests/casestmt/tcasestmt.nim +++ b/tests/casestmt/tcasestmt.nim @@ -258,7 +258,7 @@ func foo(input: string): int = try: parseInt(input) except: - 0 + return func foo2(b, input: string): int = case b: diff --git a/tests/semreject/tmixing_return_and_exprs.nim b/tests/semreject/tmixing_return_and_exprs.nim deleted file mode 100644 index 2848c47e4..000000000 --- a/tests/semreject/tmixing_return_and_exprs.nim +++ /dev/null @@ -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 - |