Skip to content

Commit 3a6716a

Browse files
committed
tests: add a test for type inference involving sink
The existing `tsink_in_array.nim` test is merged into the new test.
1 parent 7f37955 commit 3a6716a

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

tests/lang_types/array/tsink_in_array.nim

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
discard """
2+
description: '''
3+
The `sink` parameter modifier is not part of the parameter expression's
4+
effective type.
5+
'''
6+
"""
7+
8+
proc test(param: sink int8) =
9+
let tup = (param, param)
10+
let named = (a: param, b: param)
11+
let arr = [param]
12+
let se = {param}
13+
14+
# test 'typeof'
15+
var x: (typeof(param),)
16+
17+
doAssert $typeof(tup) == "(int8, int8)"
18+
doAssert $typeof(named) == "tuple[a: int8, b: int8]"
19+
doAssert $typeof(arr) == "array[0..0, int8]"
20+
doAssert $typeof(se) == "set[int8]"
21+
doAssert $typeof(x) == "(int8,)"
22+
23+
test(1)
24+
25+
# test parameter type inference from default value expression
26+
proc param_test(x: sink int, y = x) =
27+
discard
28+
29+
doAssert $typeof(param_test) == "proc (x: sink int, y: int){.noSideEffect, gcsafe, locks: 0.}"

0 commit comments

Comments
 (0)