nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.54k stars 1.47k forks source link

Error using toSeq in map #16439

Open hbwales opened 3 years ago

hbwales commented 3 years ago

Using toSeq in map causes and internal error

Example

import strutils, sequtils
var data = "aaa aaa"
echo data.split(" ").map(toSeq)

Current Output

Error: internal error: D:\a\nightlies\nightlies\nim-1.4.2\compiler\seminst.nim(328, 18)
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details

Expected Output

@[@['a', 'a', 'a'], @['a', 'a', 'a']]

Additional Information

$nim -v
Nim Compiler Version 1.4.2 [Windows: amd64]
timotheecour commented 3 years ago

https://github.com/nim-lang/Nim/pull/11992 would fix this (and the general case as well), until then you can use mapIt instead of map

when true:
  import strutils, sequtils
  var data = "aaa aaa"
  echo data.split(" ").mapIt(toSeq(it))