33 Commits

Author SHA1 Message Date
ringabout
5abd21dfa5 fixes #25123; fixes #11862; Case object from compileTime proc unable to be passed as static param (#25224)
fixes #25123; fixes #11862

follow up https://github.com/nim-lang/Nim/pull/24442
ref https://github.com/nim-lang/Nim/pull/24441

> To fix this, fields from inactive branches are now detected in
semmacrosanity.annotateType (called in fixupTypeAfterEval) and marked to
prevent the codegen of their assignments. In
https://github.com/nim-lang/Nim/pull/24441 these fields were excluded
from the resulting node, but this causes issues when the node is
directly supposed to go back into the VM, for example as const values. I
don't know if this is the only case where this happens, so I wasn't sure
about how to keep that implementation working.

Object variants fields coming from inactive branches from VM are now
flagged `nfPreventCg`. We can ignore them, as done by the C backends.
2025-10-16 18:22:46 +02:00
metagn
1bebc236bd fix type of reconstructed kind field node in field checking analysis [backport] (#24290)
fixes #24021

The field checking for case object branches at some point generates a
negated set `contains` check for the object discriminator. For enum
types, this tries to generate a complement set and convert to a
`contains` check in that instead. It obtains this type from the type of
the element node in the `contains` check.

`buildProperFieldCheck` creates the element node by changing a field
access expression like `foo.z` into `foo.kind`. In order to do this, it
copies the node `foo.z` and sets the field name in the node to the
symbol `kind`. But when copying the node, the type of the original
`foo.z` is retained. This means that the complement is performed on the
type of the accessed field rather than the type of the discriminator,
which causes problems when the accessed field is also an enum.

To fix this, we properly set the type of the copied node to the type of
the kind field. An alternative is just to make a new node instead.

A lot of text for a single line change, I know, but this part of the
codebase could use more explanation.
2024-10-12 21:20:21 +02:00
ringabout
39f2df1972 fixes #23295; don't expand constants for complex structures (#23297)
fixes #23295
2024-02-20 07:31:58 +01:00
flywind
9c17a32e0e fix #19266; allow reassign discriminant field (#19567)
* add inUncheckedAssignSection

* add one more test
2022-02-25 20:33:28 +01:00
Andreas Rumpf
cddf8ec6f6 implements https://github.com/nim-lang/RFCs/issues/407 (#18793) 2021-09-03 21:52:24 +02:00
flywind
7bfb9f0002 close #17636 (#17643) 2021-04-06 16:20:01 +02:00
flywind
70a30317f7 fix #16693: testament spec nimout too lax (#16698)
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-04-04 13:47:28 -07:00
flywind
3021252ad4 close #14581 add testcase (#17169)
* remove unnecessary when statement

* remove outdated codes

* close #14581
2021-02-24 13:49:47 +01:00
flywind
6d442a40a6 use doAssert in tests (#16486) 2020-12-28 14:13:21 +01:00
Jasper Jenkins
3c38edf563 Better case coverage error message for alias and range enum (#12913) 2019-12-18 10:29:01 +01:00
Clyybber
cf5c3f2400 Fixes #12379 (#12591) [backport] 2019-11-04 20:57:14 +01:00
Nindaleth
34dbc5699e fix several typos in documentation and comments (#12553) 2019-10-30 09:08:45 +01:00
Oscar Nihlgård
4264e9576d Consider range type of runtime discrim [feature] (#11432) 2019-08-20 17:39:49 +02:00
Jasper Jenkins
fc4f0808c4 parameter runtime discriminators (#11397)
* allow param for runtime discriminator construction
2019-06-04 22:10:39 +02:00
Araq
795044ed2b make tests green again 2019-05-27 21:29:02 +02:00
Jasper Jenkins
f774426095 Smarter variant object construction (#11273) 2019-05-26 21:22:02 +02:00
Jasper Jenkins
90ed904c4d range/case fixes (#11264) 2019-05-16 16:36:40 +02:00
Araq
bdb67201b2 fixes #10033 [backport] 2018-12-22 18:39:20 +01:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Araq
562d185cb7 cleanup tests; don't use non-working 'msg' spec field 2018-11-23 13:16:45 +01:00
Arne Döring
e012eb1001 updated tests to be executed 2018-11-23 11:58:28 +01:00
Araq
02b78d3f94 make tests green again 2018-05-14 21:38:18 +02:00
Andreas Rumpf
74fe7a800b make tests green again 2018-05-02 13:34:54 +02:00
Araq
824092be31 fixes a regression about static object case variant checking 2018-04-06 13:01:24 +02:00
Araq
b57d14b1ae make more tests green 2018-02-10 20:55:22 +01:00
superfunc
0ce26313a4 Add test for objvariant construction order
Fixes #4665
2017-09-09 15:45:19 -07: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
def
cb3c99fe1f Fix tests some more 2015-03-17 00:02:47 +01:00
Araq
c2da0e9b3d cleanup index generation 2015-02-10 20:19:48 +01:00
Araq
30823c1ce3 make tests green 2014-08-31 15:15:26 +02:00
Araq
4d8c127838 made some tests green 2014-08-13 01:30:42 +02:00
Araq
62a10df765 fixes yet another option type 2014-04-03 07:54:58 +02:00
Araq
20b5f31c03 new tester; all tests categorized 2014-01-13 02:10:03 +01:00