summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* Make math.isNaN,copySign,etc available on objc (#24025)lit2024-09-051-1/+1
| | | | | | | fixes #23922 --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* remove unused nimStdlibVersion (#24060)ringabout2024-09-042-19/+1
|
* Make `$` on 0-length `MemSlice` produce Nim "" as per DMisener idea (#24015)c-blake2024-09-041-1/+1
| | | | | | | | in https://forum.nim-lang.org/t/12463 which seems reasonable enough to me. stdlib has several dozens of places doing result.setLen now, but if `experimental:strictDefs` move sot on by default and there is no easy way to locally suppress the warning we can revisit this.
* streams: implement readStr for VM, document VM limitations (#24058)metagn2024-09-043-4/+17
| | | | | | | | | | | fixes #24054 `readData` is not implemented for the VM as mentioned in the issue, but `readDataStr` is, so that is used for `readStr` instead on the VM. We could also just use it in general since it falls back to `readData` anyway but it's kept the same otherwise for now. Also where and why streams in general don't work in VM is now documented on the top level `streams` module documentation.
* document partial generics breaking changes (#24055)metagn2024-09-041-0/+13
| | | refs #24010, split from #24051
* proper error for calling nil closure in VM (#24059)metagn2024-09-043-0/+35
| | | | | | fixes #24057 Instead of crashing the compiler, the VM now gives a stacktrace if a nil closure is attempted to be called.
* fixes symbolName for range enums (#24052)ringabout2024-09-032-1/+17
|
* fixes push warnings for sempass2 (#23603)ringabout2024-09-039-37/+87
| | | ref https://forum.nim-lang.org/t/11590
* allow conversions between `var` types of range types and base types (#24037)metagn2024-09-035-22/+81
| | | | | | | | | | | | | | | | | | | | | | | refs #24032, split from #24036 Conversion from variables of range types or base types of range types to the other are now considered mutable for `var` params, similar to how distinct types are mutable when converted to their base type or vice versa. There are 2 main differences: 1. Conversions from base types to range types need to emit `nkChckRange`, which is not generated for things like tuple/object fields. 2. Range types can still correspond to different types in the backend when nested in other types, such as `set[range[3..5]]` vs `set[range[0..5]]`. Since the convertibility check for `var` params and a check whether to emit a no-op for `nkConv` (and now also `nkChckRange`) so that the output is still addressable both use `sameType`, we accomplish this by adding a new flag to `sameType` that ignores range types, but only when they're not nested in other types. The implementation for this might be flawed, I didn't include children of some metatypes as "nested in other types", but stuff like `tyGenericInst` params are respected.
* fully disable static paramTypesMatch for tyFromExpr in generics (#24049)metagn2024-09-032-5/+12
| | | | | | | | | | | | fixes #24044 When matching a `tyFromExpr` against a `static` generic parameter, `paramTypesMatch` tries to evaluate it as a constant expression, which causes a segfault in the case of #24044. In #24005 a consequence of the same behavior was an issue where `nkStaticExpr` was created for `tyFromExpr` which made it not instantiate, so only the generation of `nkStaticExpr` was disabled. Instead we now just completely ignore `tyFromExpr` matching a `static` generic parameter in generic contexts and keep it untouched.
* fix segfault with gensym node instantiation (#24050)metagn2024-09-032-1/+31
| | | | | | | | | | | fixes #24048 Generic lambdas get instantiated via `replaceTypesInBody` which calls `replaceTypeVarsN` on the body of the lambda. This body can contain sym nodes of gensym symbols generated by macros, which have `nil` type. But a piece of code in `replaceTypeVarsN` checks whether the type of a symbol is equal to `void` without checking if it's `nil` first, which causes a segfault. Now it also checks that the type of the symbol isn't `nil` for it to be `void`.
* handle explicit generic routine instantiations in sigmatch (#24010)metagn2024-09-0222-118/+436
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #16376 The way the compiler handled generic proc instantiations in calls (like `foo[int](...)`) up to this point was to instantiate `foo[int]`, create a symbol for the instantiated proc (or a symchoice for multiple procs excluding ones with mismatching generic param counts), then perform overload resolution on this symbol/symchoice. The exception to this was when the called symbol was already a symchoice node, in which case it wasn't instantiated and overloading was called directly ([these lines](https://github.com/nim-lang/Nim/blob/b7b1313d21deb687adab2b4a162e716ba561a26b/compiler/semexprs.nim#L3366-L3371)). This has several problems: * Templates and macros can't create instantiated symbols, so they couldn't participate in overloaded explicit generic instantiations, causing the issue #16376. * Every single proc that can be instantiated with the given generic params is fully instantiated including the body. #9997 is about this but isn't fixed here since the instantiation isn't in a call. The way overload resolution handles explicit instantiations by itself is also buggy: * It doesn't check constraints. * It allows only partially providing the generic parameters, which makes sense for implicit generics, but can cause ambiguity in overloading. Here is how this PR deals with these problems: * Overload resolution now always handles explicit generic instantiations in calls, in `initCandidate`, as long as the symbol resolves to a routine symbol. * Overload resolution now checks the generic params for constraints and correct parameter count (ignoring implicit params). If these don't match, the entire overload is considered as not matching and not instantiated. * Special error messages are added for mismatching/missing/extra generic params. This is almost all of the diff in `semcall`. * Procs with matching generic parameters now instantiate only the type of the signature in overload resolution, not the proc itself, which also works for templates and macros. Unfortunately we can't entirely remove instantiations because overload resolution can't handle some cases with uninstantiated types even though it's resolved in the binding (see the last 2 blocks in `texplicitgenerics`). There are also some instantiation issues with default params that #24005 didn't fix but I didn't want this to become the 3rd huge generics PR in a row so I didn't dive too deep into trying to fix them. There is still a minor instantiation fix in `semtypinst` though for subscripts in calls. Additional changes: * Overloading of `[]` wasn't documented properly, it somewhat is now because we need to mention the limitation that it can't be done for generic procs/types. * Tests can now enable the new type mismatch errors with just `-d:testsConciseTypeMismatch` in the command. Package PRs: - using fork for now: [combparser](https://github.com/PMunch/combparser/pull/7) (partial generic instantiation) - merged: [cligen](https://github.com/c-blake/cligen/pull/233) (partial generic instantiation but non-overloaded + template) - merged: [neo](https://github.com/andreaferretti/neo/pull/56) (trying to instantiate template with no generic param)
* fixes #24033; Yielding from var fails with pairs and destructuring (#24046)ringabout2024-09-022-3/+25
| | | fixes #24033
* check constant conditions in generic `when` in objects (#24042)metagn2024-09-022-5/+58
| | | | | | | | | fixes #24041 `when` statements in generic object types normally just leave their conditions as expressions and still typecheck their branch bodies. Instead of this, when the condition can be evaluated as a constant as well as the ones before it and it resolves to `true`, it now uses the body of that branch without typechecking the remaining ones.
* fixes #24031; js codegen bug for case statement with just else branch (#24047)ringabout2024-09-022-2/+14
| | | fixes #24031
* generic issues test cases (#24028)metagn2024-08-305-0/+221
| | | | | | | | | | | | | closes #1969, closes #7547, closes #7737, closes #11838, closes #12283, closes #12714, closes #12720, closes #14053, closes #16118, closes #19670, closes #22645 I was going to wait on these but regression tests even for recent PRs are turning out to be important in wide reaching PRs like #24010. The other issues with the working label felt either finnicky (#7385, #9156, #12732, #15247), excessive to test (#12405, #12424, #17527), or I just don't know what fixed them/what the issue was (#16128: the PR link gives a server error by Github, #12457, #12487).
* fixes #24034; fixes lent types after taking implicit address (#24035)ringabout2024-08-302-0/+21
| | | fixes #24034
* remove noise from bug report issue form (#24030)metagn2024-08-291-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removes some noise from the bug report issue template so people who aren't familiar can submit issues with less friction. Some of these might be a bit subjective, feel free to call out any nitpicky parts, I didn't want to rewrite entirely. Mostly fixed typos & language issues, other than that: * Just "detailed information", no need to say "descriptive", and changed "reproducible code and detailed information" to "or detailed information" because code is good enough * Simplified description label, mention code example can go there * Changed "Possible Solution" to "Known Workarounds" because it's what issue authors are more likely to know (and usually write anyway) and is more useful to most readers. * Doc link for "rebuilding the compiler" was broken, replaced it with mentioning choosenim, nightlies and building a temp compiler which is hopefully less offputting Weird looking preview [here](https://github.com/metagn/Nim/blob/issue-templates/.github/ISSUE_TEMPLATE/bug_report.yml) Just to complain: Github issue forms have some problems themselves, there's no option to disable the "No response" text when an optional area is unfilled, and the textboxes are really small at least on Firefox (though you can expand them). The alternative, issue templates, isn't much better. Github also hides the ability to open a blank issue in a text link in a small line after all the issue form buttons, I'm guessing this is intentional for repositories which don't want blank issues but we don't have such a problem. Worst comes to worst we can add a button for a minimal/empty issue template.
* proper error message for out-of-range enum sets (#24027)metagn2024-08-293-3/+74
| | | fixes #17848
* fix `include` in templates, with prefix operators (#24029)metagn2024-08-295-12/+25
| | | | | | | | | | | fixes #12539, refs #21636 `evalInclude` now uses `getPIdent` to check if a symbol isn't `/` anymore instead of assuming it's an ident, which it's not when used in templates. Also it just checks if the symbol is `as` now, because there are other infix operators that could be used like `/../`. It also works with prefix operators now by copying what was done in #21636.
* fixes typo (#24026)ringabout2024-08-291-1/+1
|
* fixes #23923; type-aliased seq[T] get different backend C/C++ pointer type ↵ringabout2024-08-282-2/+14
| | | | | | | names causing invalid codegen (#23924) … type names causing invalid codegen fixes #23923
* Fix linux start process errorCode always 0 (#24001)握猫猫2024-08-283-14/+49
| | | | | | | | | | | | #23992 The test case provided does not cover the Windows situation, I fixed it in this new PR. Fixed an issue where errorCode was always 0 when startProcess didn't use the poEvalCommand flag. Tthe sleep command might not be available in all Windows installations, so I skipped the relevant test. Added a test case, tested on my fedora and windows systems.
* opensym for templates + move behavior of opensymchoice to itself (#24007)metagn2024-08-2818-120/+468
| | | | | | | | | | | | | | | | | | | | | | | fixes #15314, fixes #24002 The OpenSym behavior first added to generics in #23091 now also applies to templates, since templates can also capture symbols that are meant to be replaced by local symbols if the context imports symbols with the same name, as in the issue #24002. The experimental switch `templateOpenSym` is added to enable this behavior for templates only, and the experimental switch `openSym` is added to enable it for both templates and generics, and the documentation now mainly mentions this switch. Additionally the logic for `nkOpenSymChoice` nodes that were previously wrapped in `nkOpenSym` now apply to all `nkOpenSymChoice` nodes, and so these nodes aren't wrapped in `nkOpenSym` anymore. This means `nkOpenSym` can only have children of kind `nkSym` again, so it is more in line with the structure of symchoice nodes. As for why they aren't merged with `nkOpenSymChoice` nodes yet, we need some way to signal that the node shouldn't become ambiguous if other options exist at instantiation time, we already captured a symbol at the beginning and another symbol can only replace it if it's closer in scope and unambiguous.
* remove fauxMatch for tyFromExpr, remove tyProxy and tyUnknown aliases (#24018)metagn2024-08-2815-39/+31
| | | | | | | | | | | | | | | | | | | | | updated version of #22193 After #22029 and the followups #23983 and #24005 which fixed issues with it, `tyFromExpr` no longer match any proc params in generic type bodies but delay all non-matching calls until the type is instantiated. Previously the mechanism `fauxMatch` was used to pretend that any failing match against `tyFromExpr` actually matched, but prevented the instantiation of the type until later. Since this mechanism is not needed anymore for `tyFromExpr`, it is now only used for `tyError` to prevent cascading errors and changed to a bool field for simplicity. A change in `semtypes` was also needed to prevent calling `fitNode` on default param values resolving to type `tyFromExpr` in generic procs for params with non-generic types, as this would try to coerce the expression into a concrete type when it can't be instantiated yet. The aliases `tyProxy` and `tyUnknown` for `tyError` and `tyFromExpr` are also removed for uniformity.
* fixes #14623; Top-level volatileLoad/volatileStore leads to invalid codegen ↵ringabout2024-08-282-7/+20
| | | | | (#24020) fixes #14623
* use the official URL of neo (#24019)ringabout2024-08-281-1/+1
| | | ref https://github.com/andreaferretti/neo/pull/55
* fixes #23925; VM generates wrong cast for negative enum values (#23951)autumngray2024-08-272-6/+36
| | | | | | | | | | Follow up of #23927 which solves the build error. This is still only a partial fix as it doesn't take into account unordered enums. I'll make a separate issue for those. --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* make int literals with range type match their base type better than other ↵metagn2024-08-271-3/+10
| | | | | | | | | | | | | | | | int types (#24017) This is a very niche case encountered in #24012, where an int literal got a `range` type as a result of a generic instantiation (in `tgenericcomputedrange`), I can't think of another test case. The base type of the range being `int` made it match `int` with `isSubrange` as in the first `if` branch, but other int types like `int32` matched with `isFromIntLit` which is a better match. Instead, int literals with range type now: 1. match their base type with `isFromIntLit`, 2. don't match other int types with `isFromIntLit`, instead giving `isConvertible` as in the last `if` branch in `handleRange`.
* fixes #22553; regression of offsetof(T, anFieldOfUncheckedArray) (#24014)ringabout2024-08-273-3/+17
| | | | | | fixes #22553 follow up https://github.com/nim-lang/Nim/pull/21979 which introduced a char dummy member prepended to objs only containing an UncheckedArray
* bump NimVersion to 2.1.99 (2.0.2 RC2) (#24016)Miran2024-08-271-1/+1
|
* sem generic proc param types like generic types + static instantiation fixes ↵metagn2024-08-268-31/+354
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#24005) fixes #4228, fixes #4990, fixes #7006, fixes #7008, fixes #8406, fixes #8551, fixes #11112, fixes #20027, fixes #22647, refs #23854 and #23855 (remaining issue fixed), refs #8545 (works properly now with `cast[static[bool]]` changed to `cast[bool]`), refs #22342 and #22607 (disabled tests added), succeeds #23194 Parameter and return type nodes in generic procs now undergo the same `inGenericContext` treatment that nodes in generic type bodies do. This allows many of the fixes in #22029 and followups to also apply to generic proc signatures. Like #23983 however this needs some more compiler fixes, but this time mostly in `sigmatch` and type instantiations. 1. `tryReadingGenericParam` no longer treats `tyCompositeTypeClass` like a concrete type anymore, so expressions like `Foo.T` where `Foo` is a generic type don't look for a parameter of `Foo` in non-generic code anymore. It also doesn't generate `tyFromExpr` in non-generic code for any generic LHS. This is to handle a very specific case in `asyncmacro` which used `FutureVar.astToStr` where `FutureVar` is generic. 2. The `tryResolvingStaticExpr` call when matching `tyFromExpr` in sigmatch now doesn't consider call nodes in general unresolved, only nodes with `tyFromExpr` type, which is emitted on unresolved expressions by increasing `c.inGenericContext`. `c.inGenericContext == 0` is also now required to attempt instantiating `tyFromExpr`. So matching against `tyFromExpr` in proc signatures works in general now, but I'm speculating it depends on constant folding in `semExpr` for statics to match against it properly. 3. `paramTypesMatch` now doesn't try to change nodes with `tyFromExpr` type into `tyStatic` type when fitting to a static type, because it doesn't need to, they'll be handled the same way (this was a workaround in place of the static type instantiation changes, only one of the fields in the #22647 test doesn't work with it). 4. `tyStatic` matching now uses `inferStaticParam` instead of just range type matching, so `Foo[N div 2]` can infer `N` in the same way `array[N div 2, int]` can. `inferStaticParam` also disabled itself if the inferred static param type already had a node, but `makeStaticExpr` generates static types with unresolved nodes, so we only disable it if it also doesn't have a binding. This might not work very well but the static type instantiation changes should really lower the amount of cases where it's encountered. 5. Static types now undergo type instantiation. Previously the branch for `tyStatic` in `semtypinst` was a no-op, now it acts similarly to instantiating any other type with the following differences: - Other types only need instantiation if `containsGenericType` is true, static types also get instantiated if their value node isn't a literal node. Ideally any value node that is "already evaluated" should be ignored, but I'm not sure of a better way to check this, maybe if `evalConstExpr` emitted a flag. This is purely for optimization though. - After instantiation, `semConstExpr` is called on the value node if `not cl.allowMetaTypes` and the type isn't literally a `static` type. Then the type of the node is set to the base type of the static type to deal with `semConstExpr` stripping abstract types. We need to do this because calls like `foo(N)` where `N` is `static int` and `foo`'s first parameter is just `int` do not generate `tyFromExpr`, they are fully typed and so `makeStaticExpr` is called on them, giving a static type with an unresolved node.
* generate symchoice for ambiguous types in templates & generics + handle ↵metagn2024-08-2511-35/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | types in symchoices (#23997) fixes #23898, supersedes #23966 and #23990 Since #20631 ambiguous type symbols in templates are rejected outright, now we generate a symchoice for type nodes if they're ambiguous, a generalization of what was done in #22375. This is done for generics as well. Symchoices also handle type symbols better now, ensuring their type is a `typedesc` type; this probably isn't necessary for everything to work but it makes the logic more robust. Similar to #23989, we have to prepare for the fact that ambiguous type symbols behave differently than normal type symbols and either error normally or relegate to other routine symbols if the symbol is being called. Generating a symchoice emulates this behavior, `semExpr` will find the type symbol first, but since the symchoice has other symbols, it will count as an ambiguous type symbol. I know it seems spammy to carry around an ambiguity flag everywhere, but in the future when we have something like #23104 we could just always generate a symchoice, and the symchoice itself would carry the info of whether the first symbol was ambiguous. But this could harm compiler performance/memory use, it might be better to generate it only when we have to, which in the case of type symbols is only when they're ambiguous.
* fixes #23915; std/random produces different results on c/js (#24003)ringabout2024-08-252-18/+42
| | | fixes #23915
* fixes `cast` expressions introduces unnecessary copies (#24004)ringabout2024-08-233-44/+21
| | | | | | | | | | | | | | | | | It speeds up ```nim proc foo = let piece = cast[seq[char]](newSeqUninit[uint8](5220600386'i64)) foo() ``` Notes that `cast[ref](...)` is excluded because we need to keep the ref alive if the parameter is something with pointer types (e.g. `cast[ref](pointer)`or `cast[ref](makePointer(...))`) --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fix error messages for wrongly typed generic param default values (#24006)metagn2024-08-234-7/+50
| | | | | | | | | | | | | | | | | | fixes #21258 When a generic proc is instantiated, if one of the default values doesn't match the type of the parameter, `seminst` sets the default parameter node to an `nkEmpty` node with `tyError` type. `sigmatch` checks for this to give an error message if the default param is actually used, but only while actively matching the proc signature, before the proc is even instantiated. The error message also gives very little information. Now, we check for this in `updateDefaultParams` at the end of `semResolvedCall`, after the proc has been instantiated. The `nkEmpty` node also is given the original mismatching type instead rather than `tyError`, only setting `tyError` after erroring to prevent cascading errors. The error message is changed to the standard type mismatch error also giving the instantiation info of the routine.
* fixes #23956; bindUnix loses the last character on OpenBSD (#23961)Alfred Morgan2024-08-222-4/+4
| | | | | uses calculation as shown in https://man7.org/linux/man-pages/man7/unix.7.html > offsetof(struct sockaddr_un, sun_path) + strlen(sun_path) + 1
* fixes #23454; IndexDefect thrown when destructuring a lent tuple (#23993)ringabout2024-08-222-1/+40
| | | fixes #23454
* fix subscript magic giving unresolved generic param type (#23988)metagn2024-08-223-1/+27
| | | | | | | | | | | | | | | | | | | | | | fixes #19737 As in the diff, `semResolvedCall` sets the return type of a call to a proc to the type of the call. But in the case of the [subscript magic](https://nim-lang.org/docs/system.html#%5B%5D%2CT%2CI), this type is the first generic param which is also supposed to be the type of the first argument, but this is invalid, the correct type is the element type eventually given by `semSubscript`. Some lines above also [prevent the subscript magics from instantiating their params](https://github.com/nim-lang/Nim/blob/dda638c1ba985a77eac3c7518138992521884172/compiler/semcall.nim#L699) so this type ends up being an unresolved generic param. Since the type of the node is not `nil`, `prepareOperand` doesn't try to type it again, and this unresolved generic param type ends up being the final type of the node. To prevent this, we just never set the type of the node if we encountered a subscript magic. Maybe we could also rename the generic parameters of the subscript magics to stuff like `DummyT`, `DummyI` if we want this to be easier to debug in the future.
* fixes #23943; simple default value for range (#23996)ringabout2024-08-222-0/+10
| | | | | | | fixes #23943 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* don't require symbol with enum type to be constant in fitNode (#23999)metagn2024-08-222-1/+8
| | | | | | | | | | | | | | | | fixes #23998 In `fitNode` the first symbol of a symchoice that expects an enum type with the same enum type is given as the result of the `fitNode`. But `getConstExpr` is also called on it, which will return a `nil` node for nodes that aren't constant but have the enum type, like variables or proc parameters. Instead we just return the node directly since it's already typed. Normally, this `if` branch in `fitNode` shouldn't exist since `paramTypesMatch` handles it, but the way pure enum symbols work makes it really impractical to check their ambiguity, which `paramTypesMatch` won't like. If it causes problems for regular enums we can restrict this branch to just pure enums until they are hopefully eventually removed.
* Revert "Fixed an issue where `errorCode` was always 0 when `startProcess` ↵ringabout2024-08-212-25/+4
| | | | | did…" (#23995) Reverts nim-lang/Nim#23992
* Fixed an issue where `errorCode` was always 0 when `startProcess` did… ↵握猫猫2024-08-212-4/+25
| | | | | | | | | (#23992) …n't use the `poEvalCommand` flag https://forum.nim-lang.org/t/12310 Added a test case, tested on my fedora system.
* consider ambiguity for qualified symbols (#23989)metagn2024-08-206-7/+41
| | | | | | | | | | | | | fixes #23893 When type symbols are ambiguous, calls to them aren't allowed to be type conversions and only routine symbols are considered instead. But the compiler doesn't acknowledge that qualified symbols can be ambiguous, `qualifiedLookUp` directly tries to access the identifier from the module string table. Now it checks the relevant symbol iterators for any symbol after the first received symbol, in which case the symbol is considered ambiguous. `nkDotExpr` is also included in the whitelist of node kinds for ambiguous type symbols (not entirely sure why this exists, it's missing `nkAccQuoted` as well).
* sem all call nodes in generic type bodies + many required fixes (#23983)metagn2024-08-2013-44/+379
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23406, closes #23854, closes #23855 (test code of both compiles but separate issue exists), refs #23432, follows #23411 In generic bodies, previously all regular `nkCall` nodes like `foo(a, b)` were directly treated as generic statements and delayed immediately, but other call kinds like `a.foo(b)`, `foo a, b` etc underwent typechecking before making sure they have to be delayed, as implemented in #22029. Since the behavior for `nkCall` was slightly buggy (as in #23406), the behavior for all call kinds is now to call `semTypeExpr`. However the vast majority of calls in generic bodies out there are `nkCall`, and while there isn't a difference in the expected behavior, this exposes many issues with the implementation started in #22029 given how much more code uses it now. The portion of these issues that CI has caught are fixed in this PR but it's possible there are more. 1. Deref expressions, dot expressions and calls to dot expressions now handle and propagate `tyFromExpr`. This is most of the changes in `semexprs`. 2. For deref expressions to work in `typeof`, a new type flag `tfNonConstExpr` is added for `tyFromExpr` that calls `semExprWithType` with `efInTypeof` on the expression instead of `semConstExpr`. This type flag is set for every `tyFromExpr` type of a node that `prepareNode` encounters, so that the node itself isn't evaluated at compile time when just trying to get the type of the node. 3. Unresolved `static` types matching `static` parameters is now treated the same as unresolved generic types matching `typedesc` parameters in generic type bodies, it causes a failed match which delays the call instantiation. 4. `typedesc` parameters now reject all types containing unresolved generic types like `seq[T]`, not just generic param types by themselves. (using `containsGenericType`) 5. `semgnrc` now doesn't leave generic param symbols it encounters in generic type contexts as just identifiers, and instead turns them into symbol nodes. Normally in generic procs, this isn't a problem since the generic param symbols will be provided again at instantiation time (and in fact creating symbol nodes causes issues since `seminst` doesn't actually instantiate proc body node types). But generic types can try to be instantiated early in `sigmatch` which will give an undeclared identifier error when the param is not provided. Nodes in generic types (specifically in `tyFromExpr` which should be the only use for `semGenericStmt`) undergo full generic type instantiation with `prepareNode`, so there is no issue of these symbols remaining as uninstantiated generic types. 6. `prepareNode` now has more logic for which nodes to avoid instantiating. Subscripts and subscripts turned into calls to `[]` by `semgnrc` need to avoid instantiating the first operand, since it may be a generic body type like `Generic` in an expression like `Generic[int]`. Dot expressions cannot instantiate their RHS as it may be a generic proc symbol or even an undeclared identifier for generic param fields, but have to instantiate their LHS, so calls and subscripts need to still instantiate their first node if it's a dot expression. This logic still isn't perfect and needs the same level of detail as in `semexprs` for which nodes can be left as "untyped" for overloading/dot exprs/subscripts to handle, but should handle the majority of cases. Also the `efDetermineType` requirement for which calls become `tyFromExpr` is removed and as a result `efDetermineType` is entirely unused again.
* allow qualifying macro pragmas (#23985)metagn2024-08-204-9/+36
| | | fixes #12696
* Try to revert "disable presto" (#23987)ringabout2024-08-201-1/+1
| | | | | | | Reverts nim-lang/Nim#23958 follow up https://github.com/nim-lang/Nim/pull/23981 ref https://github.com/nim-lang/Nim/pull/23958#issuecomment-2294848209
* include generic bodies in allowMetaTypes (#23968)metagn2024-08-202-1/+18
| | | | | | | | fixes #19848 Not sure why this wasn't the case already. The `if cl.allowMetaTypes: return` line below for `tyFromExpr` [was added 10 years ago](https://github.com/nim-lang/Nim/commit/d5798b43dec547f372eb49d5a8848a9970b12260). Hopefully it was just negligence?
* adds a ubuntu 24.04 matrix with gcc 14 for tests (#23673)ringabout2024-08-205-3/+92
| | | ref https://forum.nim-lang.org/t/11587
* fixes #23945; type checking for whenvm expresssions (#23970)ringabout2024-08-202-16/+5
| | | fixes #23945