diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-08-20 20:41:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-20 20:41:07 +0800 |
commit | dda638c1ba985a77eac3c7518138992521884172 (patch) | |
tree | a87584420c62a68f4dcfa9a2852e06309c0dbec8 | |
parent | 43274bfb9277999b8dcc205731f574c4b9924ac4 (diff) | |
download | Nim-dda638c1ba985a77eac3c7518138992521884172.tar.gz |
fixes #23945; type checking for whenvm expresssions (#23970)
fixes #23945
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | lib/pure/md5.nim | 19 |
2 files changed, 5 insertions, 16 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 0147245af..e812aa1f6 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2686,6 +2686,8 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode = if semCheck: it[0] = semExpr(c, it[0], flags) typ = commonType(c, typ, it[0].typ) + if typ != nil and typ.kind != tyUntyped: + it[0] = fitNode(c, typ, it[0], it[0].info) if result == nil: result = it[0] else: illFormedAst(n, c.config) diff --git a/lib/pure/md5.nim b/lib/pure/md5.nim index c65a9c2da..9c3f6d51b 100644 --- a/lib/pure/md5.nim +++ b/lib/pure/md5.nim @@ -100,32 +100,19 @@ proc decode(dest: var openArray[uint8], src: openArray[uint32]) = dest[i+3] = uint8(src[j] shr 24 and 0xff'u32) inc(i, 4) -template slice(s: string, a, b): openArray[uint8] = - when nimvm: - # toOpenArray is not implemented in VM - var s2 = newSeq[uint8](s.len) - for i in 0 ..< s2.len: - s2[i] = uint8(s[i]) - s2 - else: - s.toOpenArrayByte(a, b) - template slice(s: cstring, a, b): openArray[uint8] = when nimvm: # toOpenArray is not implemented in VM - slice($s, a, b) + toOpenArrayByte($s, a, b) else: when defined(js): # toOpenArrayByte for cstring is not implemented in JS - slice($s, a, b) + toOpenArrayByte($s, a, b) else: s.toOpenArrayByte(a, b) template slice(s: openArray[uint8], a, b): openArray[uint8] = - when nimvm: - s[a .. b] - else: - s.toOpenArray(a, b) + s.toOpenArray(a, b) const useMem = declared(copyMem) |