50 Commits

Author SHA1 Message Date
metagn
aeb3fe9505 test case haul to prevent pileup (#24525)
closes #6013, closes #7009, closes #9190, closes #12487, closes #12831,
closes #13184, closes #13252, closes #14860, closes #14877, closes
#14894, closes #14917, closes #16153, closes #16439, closes #17779,
closes #18074, closes #18202, closes #18314, closes #18648, closes
#19063, closes #19446, closes #20065, closes #20367, closes #22126,
closes #22820, closes #22888, closes #23020, closes #23287, closes
#23510
2024-12-09 08:11:47 +01:00
metagn
76c5f16ac5 stricter skip for conversions in array indices in transf (#24424)
fixes #17958

In `transf`, conversions in subscript expressions are skipped (with
`skipConv`'s rules). This is because array indexing can produce
conversions to the range type that is the array's index type, which
causes a `RangeDefect` rather than an `IndexDefect` (and also
`--rangeChecks` and `--indexChecks` are both considered). However this
causes problems when explicit conversions are used, between types of
different bitsizes, because those also get skipped.

To fix this, we only skip the conversion if:

* it's a hidden (implicit) conversion
* it's a range check conversion (produces `nkChckRange`)
* the subscript is on an array type and the result type of the
conversion has the same bounds as the array index type

And `skipConv` rules also still apply (int/float classification).

Another idea would be to prevent the implicit conversion to the array
index type from being generated. But there is no good way to do this:
matching to the base type instead prevents types like `uint32` from
implicitly converting (i.e. it can convert to `range[0..3]` but not
`int`), and analyzing whether this is an array bound check is easier in
`transf`, since `sigmatch` just produces a type conversion.

The rules for skipping the conversion could also receive some other
tweaks: We could add a rule that changing bitsizes also doesn't skip the
conversion, but this breaks the `uint32` case. We could simplify it to
only removing implicit skips to specifically fix #17958, but this is
wrong in general.

We could also add something like `nkChckIndex` that generates index
errors instead but this is weird when it doesn't have access to the
collection type and it might be overkill.
2024-11-11 10:48:28 +01:00
metagn
3ab8b6b2cf error on large integer types as array index range (#23229)
fixes #17163, refs #23204

Types that aren't `tyRange` and are bigger than 16 bits, so `int32`,
`uint64`, `int` etc, are disallowed as array index range types.
`tyRange` is excluded because the max array size is backend independent
(except for the specific size of `high(uint64)` which crashes the
compiler) and so there should still be an escape hatch for people who
want bigger arrays.
2024-01-18 21:14:27 +01:00
metagn
b97d603cd0 some test cleanups & category reorganization (#22010)
* clean up some test categories

* mention exact slice issue

* magics into system

* move trangechecks into overflow

* move tmemory to system

* try fix CI

* try fix CI

* final CI fix
2023-06-06 06:54:07 +02:00
Bung
c598d0b6ec fix #15117 zero size array cause incorrect codegen for VCC compiler (#21197)
fix #15117
2022-12-30 00:50:12 +01:00
Bung
40b5c4c4c3 fix #20248;fix #6215;turns into simple CT error (#21141) 2022-12-20 20:23:48 +01:00
flywind
9df195ef58 style usages part one (openarray => openArray) (#19321)
* style usages (openArray)

* revert doc changes
2022-01-04 13:29:50 +01:00
Andreas Rumpf
018465a234 fixes #18643 [backport:1.0] (#18678) 2021-08-12 08:25:11 +02:00
Tanguy Cizain
363467fc00 Fix array's high & low return type for empty arrays (#17705)
* fix array.high/low return type

* Add test for empty array low return type

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2021-04-15 15:45:38 +02:00
Timothee Cour
e40ff24c23 typeToString: type float => typedesc[float] (#17011)
* typeToString: type float => typedesc[float]

* fixup

* fix tests
2021-02-12 17:10:20 +01:00
flywind
d447c0fe3f use typeof instead type (#16962) 2021-02-08 09:46:07 +01:00
Timothee Cour
b3c3557c33 fix #16025 repr now consistent: does not insert trailing newline (#16034) 2020-11-19 12:12:51 -08:00
Neelesh Chandola
4c08e64e98 disallow typedesc in arrays & move existing checks to types.typeAllowedAux (#13261)
* disallow typedesc in arrays and move previous checks to types.typeAllowedAux
2020-05-29 11:48:15 +02:00
Paul Tan
ad3c10022a guards.nim:sameTree(): handle uint literals correctly (#12483) [backport] 2019-10-22 18:18:33 +02:00
Andreas Rumpf
64e1408920 fixes #8316 (#11673) 2019-07-06 20:02:50 +02:00
Jasper Jenkins
8ee0f14ab6 literal array indices (#11424) 2019-06-18 14:16:33 +02:00
Vindaar
36e34d9aed close #3899 by adding test case (#10424) 2019-01-23 08:44:19 +01:00
Timothee Cour
6ce3949c8a add isNamedTuple; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) which leaked implementation detail (#10070)
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of leaking implementation detail (Field0: 1, Field1: 2)
  fixes this: #8670 (comment) /cc @alehander42 @Vindaar @mratsim

* Note: isNamedTuple is useful in other places, eg #10010 (comment)

* move isNamedTuple to helpers.nim to avoid exposing new symbol to system.nim

* remove workaround in tests/vm/tissues.nim failing test now that #10218 was makes it work
2019-01-08 18:37:25 -08:00
Andreas Rumpf
ac785b0623 testament: joinable is now an explicit concept of a test spec 2018-12-11 21:23:24 +01:00
Arne Döring
2a4c09ff88 megatest can be executed 2018-12-11 21:23:21 +01:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Araq
e71410d74e language cleanup: the .unchecked pragma is dead 2018-11-06 13:55:03 +01:00
LemonBoy
6ef198e07b Relax the restrictions on the index types (#9412) 2018-10-18 11:08:05 +02:00
Andreas Rumpf
0d48bafcf0 fixes a regression about indexing into UncheckedArray 2018-10-16 20:09:12 +02:00
Miran
7f18d7cbc1 Merge tests into a larger file (part 1 of ∞) (#9318)
* merge actiontable tests

* merge arithm tests

* merge array tests

* merge assign tests

* merge bind tests

* merge casestmt tests

* merge closure tests

* merge cnt seq tests

* merge collections tests

* merge concept issues tests

* merge concept tests

* fix failing tests

* smaller outputs

Use `doAssert` where possible.

* fix wrong output

* split `tcomputedgoto`

* revert merging concepts

* fix failing test
2018-10-12 17:02:46 +02:00
Andreas Rumpf
df4d5b77a1 introduce precise string '[]', '[]=' accessors; fixes #8049 (#8817) 2018-08-30 23:01:15 +02:00
andri lim
069a53ad4b fixes #7906, array and openarray arg vs. ptr/ref generic (#7909)
* fixes #7906, array and openarray arg vs. ptr/ref generic

* add comment
2018-06-04 17:43:15 +02:00
andri lim
25a41d5d90 fixes #7818, correct internal representation of generic objects array construction (#7824)
* defer skiptypes
* defer skiptypes for tyRef & tyPtr
* remove unneeded skipTypes
2018-05-29 09:38:52 +02:00
andri lim
07d6ff4be4 fixes #7601, array construction of ptr generics (#7671)
* fixes #7601, array construction of ptr generics

* add more test
2018-04-27 21:38:15 +02:00
Oscar Nihlgård
651c0e45da semcheck negative array length (#7518) 2018-04-06 17:05:28 +02:00
Araq
ef6eda4cb4 better error messages: use <T1, T2> instead of (T1, T2) in order to prevent confusions with tuple types 2018-02-10 20:55:21 +01:00
cooldome
51d81c4e23 Fixes #6853 (#7188)
* Fixes #6853
* Add a test for a const empty array
2018-02-10 16:44:41 +01:00
Araq
5c5e54d3a9 fixes #7153 2018-02-10 14:09:04 +01:00
Andreas Rumpf
78fb3ffeb1 fix test for bug #6989 2018-01-27 08:02:29 +01:00
Andreas Rumpf
68dfd1729e fixes #6989 2018-01-27 07:59:40 +01:00
Fabian Keller
6df6ec27ec Improved collection-to-string behavior (#6825) 2017-12-14 14:02:13 +01:00
Araq
cd6d734f8b fixes #6692 2017-11-05 02:51:32 +01:00
Andreas Rumpf
0f5261e971 fixes #6675 2017-11-02 22:09:58 +01:00
Andreas Rumpf
b14cc1e3b2 fixes #6631 2017-10-30 14:45:57 +01:00
Andreas Rumpf
8b54db06cb system.nim: typo 2017-10-29 21:32:42 +01:00
Andreas Rumpf
f1dab39086 remove old implementation of the roof operator; make tests green again; close #6292 2017-10-29 20:36:07 +01:00
ephja
ea47234b35 Array typedesc len (#6032) 2017-09-17 15:48:02 +02:00
Jacek Sieka
22684370b0 remove ArrayDummySize with unchecked arrays (#5818) 2017-08-28 15:44:35 +02:00
Andreas Rumpf
d1e199e0d8 make tests green again 2016-08-25 20:21:08 +02:00
Adam Strzelecki
e80465dacf tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
2015-09-04 23:04:32 +02:00
Araq
5d63ecb3a4 implemented a[^1] notation 2015-03-26 02:12:38 +01:00
Araq
2a1acbd1a6 fixes #1669 2014-11-22 23:09:08 +01:00
EXetoC
e69899fb49 Fix some tests. 2014-03-31 21:38:35 +02:00
Zahary Karadjov
4f91dd40ed msg -> errmsg 2014-03-21 00:27:28 +02:00
Araq
20b5f31c03 new tester; all tests categorized 2014-01-13 02:10:03 +01:00