mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 20:04:18 +00:00
fixes #23902
This commit is contained in:
@@ -2003,7 +2003,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||
if rhsTyp.kind in tyUserTypeClasses and rhsTyp.isResolvedUserTypeClass:
|
||||
rhsTyp = rhsTyp.last
|
||||
if lhs.sym.typ.kind == tyAnything:
|
||||
rhsTyp = rhsTyp.skipIntLit(c.idgen)
|
||||
rhsTyp = rhsTyp.skipTypes({tySink}).skipIntLit(c.idgen)
|
||||
if cmpTypes(c, lhs.typ, rhsTyp) in {isGeneric, isEqual}:
|
||||
internalAssert c.config, c.p.resultSym != nil
|
||||
# Make sure the type is valid for the result variable
|
||||
@@ -2825,7 +2825,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType
|
||||
n[i][1].typ = errorType(c)
|
||||
|
||||
var f = newSymS(skField, n[i][0], c)
|
||||
f.typ = skipIntLit(n[i][1].typ, c.idgen)
|
||||
f.typ = skipIntLit(n[i][1].typ.skipTypes({tySink}), c.idgen)
|
||||
f.position = i
|
||||
rawAddSon(typ, f.typ)
|
||||
typ.n.add newSymNode(f)
|
||||
@@ -2851,7 +2851,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags; expectedT
|
||||
# `const foo = [(1, {}), (2, {false})]`,
|
||||
# `const foo = if true: (0, nil) else: (1, new(int))`
|
||||
n[i] = fitNode(c, expectedElemType, n[i], n[i].info)
|
||||
addSonSkipIntLit(typ, n[i].typ, c.idgen)
|
||||
addSonSkipIntLit(typ, n[i].typ.skipTypes({tySink}), c.idgen)
|
||||
result.typ = typ
|
||||
|
||||
include semobjconstr
|
||||
|
||||
@@ -14,3 +14,11 @@ proc foo = # bug #23359
|
||||
doAssert bar.value == 42
|
||||
|
||||
foo()
|
||||
|
||||
block: # bug #23902
|
||||
proc foo(a: sink string): auto = (a, a)
|
||||
|
||||
proc bar(a: sink int): auto = return a
|
||||
|
||||
proc foo(a: sink string) =
|
||||
var x = (a, a)
|
||||
|
||||
Reference in New Issue
Block a user