Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
when true:
proc fn[T](a: seq[T], b: openArray[T]) =
echo a, ",", b
fn(seq[int].default, [1,2]) # ok
fn(@[0], [1,2]) # ok
fn(@[], [1,2]) # error
Current Output
Error: type mismatch: got <seq[empty], array[0..1, int]>
but expected one of:
proc fn[T](a: seq[T]; b: openArray[T]) [proc declared in /Users/timothee/git_clone/nim/timn/tests/nim/all/t11395.nim(40, 8)]
first type mismatch at position: 2
required type for b: openArray[T] [openArray]
but expression '[1, 2]' is of type: array[0..1, int] [array]
expression: fn(@[], [1, 2])
fn(@[], [1,2])
Expected Output
works
Possible Solution
make type inference smarter when a type contains empty, delaying resolving until later arguments are seen
type inference broken with @[]
Example
Current Output
Expected Output
works
Possible Solution
make type inference smarter when a type contains
empty
, delaying resolving until later arguments are seenAdditional Information
1.5.1 devel 6114df3c24e9c23bfbdbaa204bb100de9d170995