forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bugfix] fix nim-lang#11588, initialize SharedTable
- Loading branch information
Showing
2 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
discard """ | ||
output: ''' | ||
''' | ||
""" | ||
|
||
import sharedtables | ||
|
||
block: | ||
var | ||
table1: SharedTable[int, int] | ||
table2: SharedTable[int, int] | ||
|
||
init(table1) | ||
table1[1] = 10 | ||
assert table1.mget(1) == 10 | ||
|
||
# without init | ||
table2[5] = 15 | ||
assert table2.mget(5) == 15 | ||
|
||
|
||
block: | ||
var | ||
table1: SharedTable[int, int] | ||
table2: SharedTable[int, int] | ||
|
||
init(table1) | ||
assert table1.mgetOrPut(1, 7) == 7 | ||
assert table1.mgetOrPut(1, 99) == 7 | ||
|
||
# without init | ||
assert table2.mgetOrPut(1, 7) == 7 | ||
assert table2.mgetOrPut(1, 99) == 7 |