mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
* fixes #12747 * fix tests * improve code style Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
@@ -565,10 +565,19 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
|
|||||||
case arg.kind
|
case arg.kind
|
||||||
of nkEmpty..nkNilLit:
|
of nkEmpty..nkNilLit:
|
||||||
result = paDirectMapping
|
result = paDirectMapping
|
||||||
of nkPar, nkTupleConstr, nkCurly, nkBracket:
|
of nkDotExpr, nkDerefExpr, nkHiddenDeref, nkAddr, nkHiddenAddr:
|
||||||
result = paFastAsgn
|
result = putArgInto(arg[0], formal)
|
||||||
|
of nkCurly, nkBracket:
|
||||||
for i in 0..<arg.len:
|
for i in 0..<arg.len:
|
||||||
if putArgInto(arg[i], formal) != paDirectMapping: return
|
if putArgInto(arg[i], formal) != paDirectMapping:
|
||||||
|
return paFastAsgn
|
||||||
|
result = paDirectMapping
|
||||||
|
of nkPar, nkTupleConstr, nkObjConstr:
|
||||||
|
for i in 0..<arg.len:
|
||||||
|
let a = if arg[i].kind == nkExprColonExpr: arg[i][1]
|
||||||
|
else: arg[0]
|
||||||
|
if putArgInto(a, formal) != paDirectMapping:
|
||||||
|
return paFastAsgn
|
||||||
result = paDirectMapping
|
result = paDirectMapping
|
||||||
else:
|
else:
|
||||||
if skipTypes(formal, abstractInst).kind in {tyVar, tyLent}: result = paVarAsgn
|
if skipTypes(formal, abstractInst).kind in {tyVar, tyLent}: result = paVarAsgn
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ a: @[4, 2, 3]
|
|||||||
0
|
0
|
||||||
30
|
30
|
||||||
true
|
true
|
||||||
(allocCount: 41, deallocCount: 41)'''
|
(allocCount: 40, deallocCount: 40)'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
include system / ansi_c
|
include system / ansi_c
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ discard """
|
|||||||
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
|
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
|
||||||
output: '''button
|
output: '''button
|
||||||
clicked!
|
clicked!
|
||||||
(allocCount: 9, deallocCount: 9)'''
|
(allocCount: 7, deallocCount: 7)'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import system / ansi_c
|
import system / ansi_c
|
||||||
|
|||||||
@@ -26,3 +26,14 @@ var output = represent(s)
|
|||||||
|
|
||||||
for item in output():
|
for item in output():
|
||||||
echo item
|
echo item
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Issue #12747
|
||||||
|
|
||||||
|
type
|
||||||
|
ABC = ref object
|
||||||
|
arr: array[0x40000, pointer]
|
||||||
|
let a = ABC()
|
||||||
|
for a in a.arr:
|
||||||
|
assert a == nil
|
||||||
Reference in New Issue
Block a user