mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
fixes #5608
This commit is contained in:
@@ -1288,6 +1288,10 @@ proc genArg(p: PProc, n: PNode, param: PSym, r: var TCompRes) =
|
||||
add(r.res, a.address)
|
||||
add(r.res, ", ")
|
||||
add(r.res, a.res)
|
||||
elif n.typ.kind == tyVar and n.kind in nkCallKinds:
|
||||
# this fixes bug #5608:
|
||||
let tmp = getTemp(p)
|
||||
add(r.res, "($1 = $2, $1[0]), $1[1]" % [tmp, a.rdLoc])
|
||||
else:
|
||||
add(r.res, a.res)
|
||||
|
||||
|
||||
@@ -5,6 +5,11 @@ bar 12
|
||||
foo 12
|
||||
bar 12
|
||||
2
|
||||
12.5
|
||||
(nums: @[5, 5, 10, 5, 5, 5, 5, 5, 5, 5])
|
||||
(nums: @[5, 5, 50, 5, 5, 5, 5, 5, 5, 5])
|
||||
(nums: @[5, 5, 45, 5, 5, 5, 5, 5, 5, 5])
|
||||
(nums: @[5, 5, 9, 5, 5, 5, 5, 5, 5, 5])
|
||||
'''
|
||||
"""
|
||||
|
||||
@@ -59,3 +64,41 @@ block: # Test var arg inside case expression. #5244
|
||||
var a = "ok"
|
||||
foo(a)
|
||||
doAssert(a == "ok")
|
||||
|
||||
|
||||
proc mainowar =
|
||||
var x = 9.0
|
||||
x += 3.5
|
||||
echo x
|
||||
|
||||
mainowar()
|
||||
|
||||
|
||||
# bug #5608
|
||||
|
||||
type Foo = object
|
||||
nums : seq[float]
|
||||
|
||||
proc newFoo(len : int, default = 0.0) : Foo =
|
||||
result = Foo()
|
||||
result.nums = newSeq[float](len)
|
||||
for i in 0..(len - 1):
|
||||
result.nums[i] = default
|
||||
|
||||
proc `[]=`(f : var Foo, i : int, v : float) =
|
||||
f.nums[i] = v
|
||||
|
||||
proc `[]`(f : Foo, i : int) : float = f.nums[i]
|
||||
|
||||
proc `[]`(f : var Foo, i : int) : var float = f.nums[i]
|
||||
|
||||
var f = newFoo(10,5)
|
||||
|
||||
f[2] += 5
|
||||
echo f
|
||||
f[2] *= 5
|
||||
echo f
|
||||
f[2] -= 5
|
||||
echo f
|
||||
f[2] /= 5
|
||||
echo f
|
||||
|
||||
Reference in New Issue
Block a user