Fix fat pointers, object copying, magic double evals on JS (#9411) [backport]
* Add a test for issue #9389 * Fixes #9389. * Make object contructors copy objects properly by checking whether the expressions passed to them don't need to be copied. * Make mArrToSeq implementation actually check if a copy needs to be made. * Avoid unnecessary copy in mChr impl * Assume set constructor elements need no copy * Add a test for issue #9410 * Add a test * fix passing fat pointers (#9410) * Enhance tests * More tests and fixes * Add more (failing) tests [ci skip] * Added equality operator for fat pointers, more tests and fixes * Fix printing uninitialized strings * Fix mInc, mDec double eval, add more tests * Tests * Refactored, fixed multiple evals, revamped the tests, added missing ops * Fix ups * Fix #9643 and #9644 * add pointer normalization
This commit is contained in:
parent
07744b6e47
commit
e3e5ae287f
6 changed files with 745 additions and 83 deletions
|
|
@ -2,6 +2,10 @@ discard """
|
|||
output: '''123
|
||||
2 9
|
||||
2 9
|
||||
1 124
|
||||
true false
|
||||
100 300 100
|
||||
1
|
||||
'''
|
||||
"""
|
||||
|
||||
|
|
@ -35,3 +39,34 @@ block:
|
|||
obj.ary2[1] = 9
|
||||
|
||||
echo ary1[1], " ", obj.ary2[1]
|
||||
|
||||
block:
|
||||
type TestObj = object
|
||||
x, y: int
|
||||
|
||||
let obj = TestObj(x: 1, y: 2)
|
||||
var s = @[obj]
|
||||
s[0].x += 123
|
||||
echo obj.x, " ", s[0].x
|
||||
|
||||
block:
|
||||
var nums = {1, 2, 3, 4}
|
||||
let obj = (n: nums)
|
||||
nums.incl 5
|
||||
echo (5 in nums), " ", (5 in obj.n)
|
||||
|
||||
block:
|
||||
let tup1 = (a: 100)
|
||||
var tup2 = (t: (t2: tup1))
|
||||
var tup3 = tup1
|
||||
tup2.t.t2.a = 300
|
||||
echo tup1.a, " ", tup2.t.t2.a, " ", tup3.a
|
||||
|
||||
block:
|
||||
proc foo(arr: array[2, int]) =
|
||||
var s = @arr
|
||||
s[0] = 500
|
||||
|
||||
var nums = [1, 2]
|
||||
foo(nums)
|
||||
echo nums[0]
|
||||
Loading…
Add table
Add a link
Reference in a new issue