Commit Graph

35 Commits

Author SHA1 Message Date
metagn
b0e6d28782 fix logic for dcEqIgnoreDistinct in sameType (#24197)
fixes #22523

There were 2 problems with the code in `sameType` for
`dcEqIgnoreDistinct`:

1. The code that skipped `{tyDistinct, tyGenericInst}` only ran if the
given types had different kinds. This is fixed by always performing this
skip.
2. The code block below that checks if `tyGenericInst`s have different
values still ran for `dcEqIgnoreDistinct` since it checks if the given
types are generic insts, not the skipped types (and also only the 1st
given type). This is fixed by only invoking this block for `dcEq`;
`dcEqOrDistinctOf` (which is unused) also skips the first given type.
Arguably there is another issue here that `skipGenericAlias` only ever
skips 1 type.

These combined fix the issue (`T` is `GenericInst(V, 1, distinct int)`
and `D[0]` is `GenericInst(D, 0, distinct int)`).

#24037 shouldn't be a dependency but the diff follows it.
2024-09-29 10:23:59 +02:00
ringabout
95e5ad6927 fixes #22902; borrow from proc return type mismatch (#22908)
fixes #22902
2023-11-04 08:50:30 +01:00
metagn
90f87bcab7 fully revert generic inst sym change, test #22646 (#22653)
reverts #22642, reopens #22639, closes #22646, refs #22650, refs
https://github.com/alaviss/union/issues/51, refs #22652

The fallout is too much from #22642, we can come back to it if we can
account for all the affected code.
2023-09-06 05:45:07 +03:00
Bung
2aab03bdfb fix #19304 Borrowing std/times.format causes Error: illformed AST (#20659)
* fix #19304 Borrowing std/times.format causes Error: illformed AST

* follow suggestions

* mitigate for #4121

* improve error message
2023-08-10 16:26:23 +08:00
metagn
5139a2ec37 make borrow . work with aliases if not overriden (#22072) 2023-06-11 19:19:48 +02: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
ringabout
deaf684375 fix #9423 followup #17594: distinct generics now work in VM (#21816)
* fix #9423 distinct generics now work in vm

* fixes cpp tests

---------

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2023-05-10 11:06:14 +02:00
ringabout
1182216381 remove a special case in sigmatch; distinct pointer types no longer match nil type (#20251)
* remove a special case in sigmatch; distinct pointer types no longer match `nil` type

* add tests

* fixes tests

* Update changelog.md

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

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2022-08-23 19:27:20 +02:00
Khaled Hammouda
caf6aff06b Fix distinct requiresInit test and manual (#19901)
fix distinct test and manual
2022-06-22 12:36:30 +02:00
Jason Beetham
83a2515af7 Fixed generic distinct conversions for 'var' (#18837)
* SameTypeAux now properly traverses generic distincts

* Smarter traversal of distincts

* Removed redundant check

* Fixed nkConv for jsgen

* Added test for non distinct nkConv

* using skiptypes for distinct now

* Fixed genaddr for nkconv
2021-10-26 11:27:11 +02:00
Jason Beetham
ee2eb5cae2 Fix subranges of distinct types (#18816) [backport] 2021-09-07 17:11:08 +02:00
Timothee Cour
8ee0eda841 fix #12282 distinct now does not create erroneous copy in VM (#17594) 2021-03-31 10:15:08 +02:00
flywind
aa185c0e9b fix #13517 (#16681) 2021-01-11 15:07:48 +01:00
Ivan Bobev
3c85aa9e53 Make {.requiresInit.} to work for distinct types (#15869)
Make `requiresInit` pragma to work for distinct types in addition to
objects. Tagging of distinct types with `requiresInit` pragma was
already supported, but its impact wasn't applied. Now its behavior when
applied on distinct types is as follows.

Given the following distinct type definitions:

  ```nim
  type
    DistinctObject {.requiresInit, borrow: `.`.} = distinct MyObject
    DistinctString {.requiresInit.} = distinct string
  ```

The following code blocks will fail to compile:

  ```nim
  var foo: DistinctFoo
  foo.x = "test"
  doAssert foo.x == "test"
  ```

  ```nim
  var s: DistinctString
  s = "test"
  doAssert s == "test"
  ```

But these ones will compile successfully:

  ```nim
  let foo = DistinctFoo(Foo(x: "test"))
  doAssert foo.x == "test"
  ```

  ```nim
  let s = "test"
  doAssert s == "test"
  ```
2020-11-06 18:56:09 +00:00
flywind
6c83eb48c2 add testcase for #7165 (#15368)
* add testcase for #7165

* Remove overspecific testament spec

Co-authored-by: Clyybber <darkmine956@gmail.com>
2020-09-21 13:32:05 +02:00
Andreas Rumpf
de1ede77fe fixes #11715 (#11721) 2019-07-13 07:55:56 +02:00
Andreas Rumpf
1e97b420bb fixes #7167 (#11300)
* fixes #7167
* spec: distinct types can be ordinal types
* bootstrapping issue
2019-05-22 11:50:05 +02:00
Arne Döring
a5ecbf823f lots of small changes 2018-12-11 21:23:22 +01:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Miran
1b17c9f693 More descriptive names of test files (#9531)
* change generic `tissues` name to more specific
* change `tvarious` to more specific names
2018-10-29 17:07:27 +01:00
Araq
f8e805a614 fixes #2760 2018-10-15 10:43:56 +02:00
Miran
3c9fcc4c30 Merge tests into a larger file (part 2 of ∞) (#9335)
* merge controlflow tests

* merge distinct tests

* merge enum tests

* merge fields tests

* merge implicit tests

* merge iter issues tests
2018-10-13 14:58:31 +02:00
LemonBoy
fab4d38411 string to string conversion keeps the dest type (#9323)
Fixes #9322
2018-10-12 08:50:28 +02:00
jcosborn
dd65986795 fixes #4435 (#9185) 2018-10-09 13:34:03 +02:00
LemonBoy
e9b5a4e25d Constant folding should not drop distinct types
Fixes #9079
2018-09-27 17:08:01 +02:00
Ganesh Viswanathan
4e305c3040 Test case for #7010 2018-09-14 14:07:31 -05:00
Araq
f91a181f58 make tests green again 2018-08-13 23:16:03 +02:00
Araq
21cbf438ce make tests green 2018-05-02 13:34:54 +02:00
Araq
16260b23c7 make tests on Windows green 2017-01-31 23:05:36 +01:00
Andreas Rumpf
1690b912ca test case cleanup 2016-08-26 15:16:11 +02:00
Hans Raaf
e2e4df1702 Allowing nil for distinct types where the base type is nilable 2016-08-05 16:01:16 +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
e23857a98b fixes #2629, fixes #2641, fixes #2632, fixes #2630 2015-05-03 01:08:52 +02:00
Araq
7874c0efcb borrow dots for distinct types documented 2014-03-26 08:42:27 +01:00
Araq
20b5f31c03 new tester; all tests categorized 2014-01-13 02:10:03 +01:00