summary refs log tree commit diff stats
path: root/tests/sets
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-04-17 21:55:22 +0300
committerGitHub <noreply@github.com>2023-04-17 20:55:22 +0200
commitb0a98cc01e14a33d75866c10c290f63031dc2112 (patch)
tree8d73def13ac7699326e885be4b9bd6260aa454ea /tests/sets
parent2621f78b683592dced21cd93aa241deac8a9232f (diff)
downloadNim-b0a98cc01e14a33d75866c10c290f63031dc2112.tar.gz
warn on set types bigger than max size, default to 0..255 for int literals (#21659)
* test implicitly huge set types

refs https://github.com/nim-lang/RFCs/issues/298

* oh my god

* boot at least

* don't error, fix remaining issues, no 2 len arrays

* fix runnable example

* test assuming 0..255 for int literal

* test refactor, add changelog, test
Diffstat (limited to 'tests/sets')
-rw-r--r--tests/sets/thugeset.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/sets/thugeset.nim b/tests/sets/thugeset.nim
new file mode 100644
index 000000000..1d82ebede
--- /dev/null
+++ b/tests/sets/thugeset.nim
@@ -0,0 +1,10 @@
+let x = 20_000
+let s = {x, 123} #[tt.Warning
+        ^ type 'int' is too big to be a `set` element, assuming a range of 0..65535, explicitly write this range to get rid of warning [AboveMaxSizeSet]]#
+doAssert x in s
+doAssert 20_000 in s
+{.push warningAsError[AboveMaxSizeSet]: on.}
+let s2 = {range[0..65535](x), 123}
+doAssert x in s
+doAssert 20_000 in s
+{.pop.}