mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-23 07:45:23 +00:00
Prevent the construction of recursive tyStatic types (#9256)
Fixes #9255
(cherry picked from commit b8d2f79ef0)
This commit is contained in:
@@ -1911,10 +1911,13 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
|
||||
else:
|
||||
var evaluated = c.semTryConstExpr(c, arg)
|
||||
if evaluated != nil:
|
||||
arg.typ = newTypeS(tyStatic, c)
|
||||
arg.typ.sons = @[evaluated.typ]
|
||||
arg.typ.n = evaluated
|
||||
a = arg.typ
|
||||
# Don't build the type in-place because `evaluated` and `arg` may point
|
||||
# to the same object and we'd end up creating recursive types (#9255)
|
||||
let typ = newTypeS(tyStatic, c)
|
||||
typ.sons = @[evaluated.typ]
|
||||
typ.n = evaluated
|
||||
arg.typ = typ
|
||||
a = typ
|
||||
else:
|
||||
if m.callee.kind == tyGenericBody:
|
||||
if f.kind == tyStatic and typeRel(m, f.base, a) != isNone:
|
||||
|
||||
Reference in New Issue
Block a user