fixes #5608
This commit is contained in:
parent
2b72f775e2
commit
674db58a24
2 changed files with 47 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue