mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-20 11:30:43 +00:00
* fix #14243 Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
@@ -402,14 +402,18 @@ proc turnFinalizerIntoDestructor(c: PContext; orig: PSym; info: TLineInfo): PSym
|
||||
# Replace nkDerefExpr by nkHiddenDeref
|
||||
# nkDeref is for 'ref T': x[].field
|
||||
# nkHiddenDeref is for 'var T': x<hidden deref [] here>.field
|
||||
proc transform(n: PNode; old, fresh: PType; oldParam, newParam: PSym): PNode =
|
||||
proc transform(procSym: PSym; n: PNode; old, fresh: PType; oldParam, newParam: PSym): PNode =
|
||||
result = shallowCopy(n)
|
||||
if sameTypeOrNil(n.typ, old):
|
||||
result.typ = fresh
|
||||
if n.kind == nkSym and n.sym == oldParam:
|
||||
result.sym = newParam
|
||||
if n.kind == nkSym:
|
||||
if n.sym == oldParam:
|
||||
result.sym = newParam
|
||||
elif n.sym.owner == orig:
|
||||
result.sym = copySym(n.sym)
|
||||
result.sym.owner = procSym
|
||||
for i in 0 ..< safeLen(n):
|
||||
result[i] = transform(n[i], old, fresh, oldParam, newParam)
|
||||
result[i] = transform(procSym, n[i], old, fresh, oldParam, newParam)
|
||||
#if n.kind == nkDerefExpr and sameType(n[0].typ, old):
|
||||
# result =
|
||||
|
||||
@@ -423,7 +427,7 @@ proc turnFinalizerIntoDestructor(c: PContext; orig: PSym; info: TLineInfo): PSym
|
||||
let newParam = newSym(skParam, oldParam.name, result, result.info)
|
||||
newParam.typ = newParamType
|
||||
# proc body:
|
||||
result.ast = transform(orig.ast, origParamType, newParamType, oldParam, newParam)
|
||||
result.ast = transform(result, orig.ast, origParamType, newParamType, oldParam, newParam)
|
||||
# proc signature:
|
||||
result.typ = newProcType(result.info, result)
|
||||
result.typ.addParam newParam
|
||||
|
||||
@@ -104,4 +104,18 @@ proc re(x: static[string]): static MyType =
|
||||
proc match(inp: string, rg: static MyType) =
|
||||
doAssert rg.a.len == 0
|
||||
|
||||
match("ac", re"a(b|c)")
|
||||
match("ac", re"a(b|c)")
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# issue #14243
|
||||
|
||||
type
|
||||
Game* = ref object
|
||||
|
||||
proc free*(game: Game) =
|
||||
let a = 5
|
||||
|
||||
proc newGame*(): Game =
|
||||
new(result, free)
|
||||
|
||||
var game*: Game
|
||||
Reference in New Issue
Block a user