fixes #21377; fixes @[] and {} type inference as returns in generics (#21475)

* fixes `@[]` type inference in generics

* add issue links

* fixes macros and iterators

* refactor

* add one more test
This commit is contained in:
ringabout 2023-03-06 22:30:22 +08:00 • committed by GitHub
commit 64a0355f3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 5 deletions

View file

@ -245,7 +245,7 @@ block: # bug #11777
var s: S = {1, 2}
doAssert 1 in s
block: # regression #20807
block: # bug #20807
var s: seq[string]
template fail =
s = @[]
@ -255,3 +255,38 @@ block: # regression #20807
test: fail()
doAssert not (compiles do:
let x: seq[int] = `@`[string]([]))
block: # bug #21377
proc b[T](v: T): seq[int] =
let x = 0
@[]
doAssert b(0) == @[]
block: # bug #21377
proc b[T](v: T): seq[T] =
let x = 0
@[]
doAssert b(0) == @[]
block: # bug #21377
proc b[T](v: T): set[bool] =
let x = 0
{}
doAssert b(0) == {}
block: # bug #21377
proc b[T](v: T): array[0, int] =
let x = 0
[]
doAssert b(0) == []
block: # bug #21377
proc b[T](v: T): array[0, (string, string)] =
let x = 0
{:}
doAssert b(0) == {:}