Skip to content

Commit

Permalink
fixes #19201; fixes sink causes crash in VM (#20658)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Oct 25, 2022
1 parent 3b973f3 commit 4b377b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/vmgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
of mLengthOpenArray, mLengthArray, mLengthSeq:
genUnaryABI(c, n, dest, opcLenSeq)
of mLengthStr:
case n[1].typ.kind
case n[1].typ.skipTypes(abstractVarRange).kind
of tyString: genUnaryABI(c, n, dest, opcLenStr)
of tyCstring: genUnaryABI(c, n, dest, opcLenCstring)
else: doAssert false, $n[1].typ.kind
Expand Down
8 changes: 7 additions & 1 deletion tests/vm/tvmmisc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ block:
static:
foo(int)

# #4412
# bug #4412
block:
proc default[T](t: typedesc[T]): T {.inline.} = discard

Expand Down Expand Up @@ -595,3 +595,9 @@ proc main() = # bug #12994

static: main()
main()

# bug #19201
proc foo(s: sink string) = doAssert s.len == 3

static:
foo("abc")

0 comments on commit 4b377b0

Please sign in to comment.