diff options
Diffstat (limited to 'tests/stmt')
-rw-r--r-- | tests/stmt/tforloop_tuple_multiple_underscore.nim | 10 | ||||
-rw-r--r-- | tests/stmt/tforloop_tuple_underscore.nim | 16 | ||||
-rw-r--r-- | tests/stmt/tforloop_underscore.nim | 6 | ||||
-rw-r--r-- | tests/stmt/tgenericsunderscore.nim | 4 | ||||
-rw-r--r-- | tests/stmt/tmiscunderscore.nim | 15 |
5 files changed, 51 insertions, 0 deletions
diff --git a/tests/stmt/tforloop_tuple_multiple_underscore.nim b/tests/stmt/tforloop_tuple_multiple_underscore.nim new file mode 100644 index 000000000..96804df18 --- /dev/null +++ b/tests/stmt/tforloop_tuple_multiple_underscore.nim @@ -0,0 +1,10 @@ +discard """ + errormsg: "the special identifier '_' is ignored in declarations and cannot be used" +""" + +iterator iter(): (int, int, int) = + yield (1, 1, 2) + + +for (_, i, _) in iter(): + echo _ diff --git a/tests/stmt/tforloop_tuple_underscore.nim b/tests/stmt/tforloop_tuple_underscore.nim new file mode 100644 index 000000000..eda42d527 --- /dev/null +++ b/tests/stmt/tforloop_tuple_underscore.nim @@ -0,0 +1,16 @@ +discard """ + errormsg: "the special identifier '_' is ignored in declarations and cannot be used" +""" + +iterator iter(): (int, int) = + yield (1, 2) + yield (3, 4) + yield (1, 2) + yield (3, 4) + yield (1, 2) + yield (3, 4) + + +for (_, i) in iter(): + echo _ + diff --git a/tests/stmt/tforloop_underscore.nim b/tests/stmt/tforloop_underscore.nim new file mode 100644 index 000000000..ce1c86386 --- /dev/null +++ b/tests/stmt/tforloop_underscore.nim @@ -0,0 +1,6 @@ +discard """ + errormsg: "the special identifier '_' is ignored in declarations and cannot be used" +""" + +for _ in ["a"]: + echo _ diff --git a/tests/stmt/tgenericsunderscore.nim b/tests/stmt/tgenericsunderscore.nim new file mode 100644 index 000000000..be2b8ec78 --- /dev/null +++ b/tests/stmt/tgenericsunderscore.nim @@ -0,0 +1,4 @@ +# issue #21435 + +proc foo[_](x: typedesc[_]): string = "BAR" #[tt.Error + ^ the special identifier '_' is ignored in declarations and cannot be used]# diff --git a/tests/stmt/tmiscunderscore.nim b/tests/stmt/tmiscunderscore.nim new file mode 100644 index 000000000..c4bae1c3d --- /dev/null +++ b/tests/stmt/tmiscunderscore.nim @@ -0,0 +1,15 @@ +import std/assertions + +block: + proc _() = echo "one" + doAssert not compiles(_()) + proc _() = echo "two" + doAssert not compiles(_()) + +block: + type _ = int + doAssert not (compiles do: + let x: _ = 3) + type _ = float + doAssert not (compiles do: + let x: _ = 3) |