mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 06:20:38 +00:00
Merge pull request #8990 from LemonBoy/fix-8259
Always check the deduced type validity for result
This commit is contained in:
@@ -1560,6 +1560,8 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||
rhsTyp = rhsTyp.lastSon
|
||||
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
|
||||
typeAllowedCheck(c.config, n.info, rhsTyp, skResult)
|
||||
lhs.typ = rhsTyp
|
||||
c.p.resultSym.typ = rhsTyp
|
||||
c.p.owner.typ.sons[0] = rhsTyp
|
||||
|
||||
7
tests/openarray/t8259.nim
Normal file
7
tests/openarray/t8259.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
discard """
|
||||
line: 6
|
||||
errormsg: "invalid type: 'openarray[int]' for result"
|
||||
"""
|
||||
|
||||
proc foo(a: openArray[int]):auto = a
|
||||
echo foo(toOpenArray([1, 2], 0, 2))
|
||||
Reference in New Issue
Block a user