timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

Compiler crash, no traceback, concepts #796

Open juancarlospaco opened 3 years ago

juancarlospaco commented 3 years ago
type Iterable[T] = concept x
  for value in x:
    value is T

func ani[T](iter: Iterable[T]): bool =
  result = false
  for element in iter:
    if bool(element):
      return true

discard ani([true, false])
$ nim c file.nim
58758 lines; 1.440s; 76.566MiB peakmem; proj: file.nim; out: file [SuccessX]

$ nim cpp file.nim
26606 lines; 0.397s; 32.035MiB peakmem; proj: file.nim; out: file [SuccessX]

$ nim js file.nim
internal error: expr(nkBracketExpr, tyUserTypeClassInst)
No stack traceback available

$

Reduced from a library that mimics some Python-like constructs, works for C/CPP, but compiler crashes for JS targets.