mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-11 22:08:54 +00:00
fixes #25494;
This commit is contained in:
@@ -813,7 +813,7 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PTyp
|
||||
inc(lastIndex)
|
||||
if isGeneric:
|
||||
for i in 0..<result.len:
|
||||
if isIntLit(result[i].typ):
|
||||
if result[i].typ != nil and isIntLit(result[i].typ):
|
||||
# generic instantiation strips int lit type which makes conversions fail
|
||||
result[i].typ = nil
|
||||
result.typ = nil # current result.typ is invalid, index type is nil
|
||||
@@ -2800,7 +2800,7 @@ proc semSetConstr(c: PContext, n: PNode, expectedType: PType = nil): PNode =
|
||||
expectedElementType = typ
|
||||
if isGeneric:
|
||||
for i in 0..<n.len:
|
||||
if isIntLit(n[i].typ):
|
||||
if n[i].typ != nil and isIntLit(n[i].typ):
|
||||
# generic instantiation strips int lit type which makes conversions fail
|
||||
n[i].typ = nil
|
||||
result.add n[i]
|
||||
@@ -2913,7 +2913,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType
|
||||
result.add n[i]
|
||||
if isGeneric:
|
||||
for i in 0..<result.len:
|
||||
if isIntLit(result[i][1].typ):
|
||||
if result[i][1].typ != nil and isIntLit(result[i][1].typ):
|
||||
# generic instantiation strips int lit type which makes conversions fail
|
||||
result[i][1].typ = nil
|
||||
result.typ = makeTypeFromExpr(c, result.copyTree)
|
||||
@@ -2954,7 +2954,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags; expectedT
|
||||
addSonSkipIntLit(typ, n[i].typ.skipTypes({tySink}), c.idgen)
|
||||
if isGeneric:
|
||||
for i in 0..<result.len:
|
||||
if isIntLit(result[i].typ):
|
||||
if result[i].typ != nil and isIntLit(result[i].typ):
|
||||
# generic instantiation strips int lit type which makes conversions fail
|
||||
result[i].typ = nil
|
||||
result.typ = makeTypeFromExpr(c, result.copyTree)
|
||||
|
||||
@@ -892,3 +892,13 @@ block: # https://github.com/nim-lang/Nim/issues/20416
|
||||
proc p2[T](sg:Container[T]) = discard
|
||||
var v : Container[int]
|
||||
p2(v)
|
||||
|
||||
block: # issue #25494
|
||||
proc foo[T: enum](s = {T.low..T.high}) =
|
||||
discard
|
||||
|
||||
type
|
||||
MyEnum = enum
|
||||
a, b, c
|
||||
|
||||
foo[MyEnum]()
|
||||
|
||||
Reference in New Issue
Block a user