summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/vmgen.nim2
-rw-r--r--tests/vm/tvmmisc.nim8
2 files changed, 8 insertions, 2 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 56764ef94..dbe053030 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -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
diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim
index ad1dfc3df..2ce4703b0 100644
--- a/tests/vm/tvmmisc.nim
+++ b/tests/vm/tvmmisc.nim
@@ -9,7 +9,7 @@ block:
   static:
     foo(int)
 
-# #4412
+# bug #4412
 block:
   proc default[T](t: typedesc[T]): T {.inline.} = discard
 
@@ -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")