Files
Nim/tests/misc
metagn a93c5d79b9 adapt generic default parameters to recent generics changes (#24065)
fixes #16700, fixes #20916, refs #24010

Fixes the instantiation issues for proc param default values encountered
in #24010 by:

1. semchecking generic default param values with `inGenericContext` for
#22029 and followups to apply (the bigger change in semtypes),
2. rejecting explicit generic instantiations with unresolved generic
types inside `inGenericContext` (sigmatch change),
3. instantiating the default param values using `prepareNode` rather
than an insufficient manual method (the bigger change in seminst).

This had an important side effect of references to other parameters not
working since they would be resolved as a symbol belonging to the
uninstantiated original generic proc rather than the later instantiated
proc. There is a more radical way to fix this which is generating ident
nodes with `tyFromExpr` in specifically this context, but instead we
just count them as belonging to the same proc in
`hoistParamsUsedInDefault`.

Other minor bugfixes:

* To make the error message in t20883 make sense, we now give a "cannot
instantiate" error when trying to instantiate a proc generic param with
`tyFromExpr`.
* Object constructors as default param values generated default values
of private fields going through `evalConstExpr` more than once, but the
VM doesn't mark the object fields as `nfSkipFieldChecking` which gives a
"cannot access field" error. So the VM now marks object fields it
generates as `nfSkipFieldChecking`. Not sure if this affects VM
performance, don't see why it would.
* The nkRecWhen changes in #24042 didn't cover the case where all
conditions are constantly false correctly, this is fixed with a minor
change. This isn't needed for this PR now but I encountered it after
forgetting to `dec c.inGenericContext`.
2024-09-06 11:44:38 +02:00
..
2022-10-02 06:44:10 +02:00
2019-09-13 07:46:46 +02:00
2023-08-06 15:21:24 +08:00
2022-12-28 08:28:48 +01:00
2023-09-26 17:40:18 +08:00
2022-12-22 06:16:25 +01:00
2022-06-10 20:40:34 +02:00
2023-01-13 15:36:13 +01:00
2022-12-27 12:07:15 +01:00
2022-10-02 06:44:10 +02:00
2022-12-19 12:35:15 +01:00
2014-06-03 19:05:13 -04:00
2020-03-30 13:18:12 +02:00
2018-11-23 11:58:28 +01:00
2019-08-31 07:44:53 +02:00
2018-11-23 11:58:28 +01:00
2018-11-23 11:58:28 +01:00
2020-07-15 03:46:17 -04:00
2018-11-23 11:58:28 +01:00
2018-11-23 11:58:28 +01:00
2023-04-17 20:56:52 +02:00
2019-07-25 09:25:18 +02:00
2019-07-25 09:25:18 +02:00
2019-05-27 21:29:02 +02:00
2020-01-16 14:21:12 +01:00
2019-11-05 11:05:46 +01:00
2018-11-23 11:58:28 +01:00
2019-11-05 11:05:46 +01:00
2018-11-23 11:58:28 +01:00
2018-11-23 11:58:28 +01:00
2022-11-25 17:39:50 +08:00