fixes #23755; array static inference during overload resolution (#23760)
--------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de> (cherry picked from commit 27abcdd)
update CI to macos 13 (#24157)
Followup to #24154, packages aren't ready for macos 14 (M1/ARM CPU) yet and it seems to be preview on azure, so upgrade to macos 13 for now. Macos 12 gives a warning: ``` You are using macOS 12. We (and Apple) do not provide support for this old version. It is expected behaviour that some formulae will fail to build in this old version. It is expected behaviour that Homebrew will be buggy and slow. Do not create any issues about this on Homebrew's GitHub repositories. Do not create any issues even if you think this message is unrelated. Any opened issues will be immediately closed without response. Do not ask for help from Homebrew or its maintainers on social media. You may ask for help in Homebrew's discussions but are unlikely to receive a response. Try to figure out the problem yourself and submit a fix as a pull request. We will review it but may or may not accept it. ``` (cherry picked from commit 4a63186)
test more Status' packages, refs #24266 (#24275)
This adds several new Status packages to the CIs: - confutils - eth - metrics - nat_traversal - toml_serialization Other packages mentioned in #24266 are currently not ready to test with `devel` for various reasons. ---- This also enables `criterion`, and removes other packages that had been in the `allowFailure` category — even without them we have plenty of packages (145) that we test, there's no point in spending CI time on them just to see them fail every time. If/when the authors of those packages make them work with Nim devel, we can re-introduce them then. (cherry picked from commit 2747626)
make linter use lineinfo to check originating package (#24270)
fixes #24269, refs #20095 Instead of checking the package of the *used sym* to determine whether a stylecheck should trigger, we check the package of the lineinfo instead. Before #20095 this checked for the current compilation context module instead which caused issues with generic procs, but the lineinfo should more closely match the AST. I figured this might cause issues with includes etc but the foreign package test specifically tests for an include and passes, so maybe the package determining logic accounts for this already. This still might not be the correct logic, I'm not too familiar with the package handling in the compiler. Package PRs, both merged: - json_rpc: status-im/nim-json-rpc#226 - json_serialization: status-im/nim-json-serialization#99 (cherry picked from commit aaf6c40)
make package testing faster (#24284)
There's no need to run benchmarks for cow- and sso-strings: they take 15 minutes each to run. (cherry picked from commit f5cb392)
reset inTypeofContext in generic instantiations (#24229)
fixes #24228, refs #22022 As described in #24228 (comment), instantiating generic routines inside `typeof` causes all code inside to be treated as being in a typeof context, and thus preventing compile time proc folding, causing issues when code is generated for the instantiated routine. Now, instantiated generic procs are treated as never being inside a `typeof` context. This is probably an arbitrary special case and more issues with the `typeof` behavior from #22022 are likely. Ideally this behavior would be removed but it's necessary to accomodate the current [proc `declval` in the package `stew`](status-im/nim-stew#190), at least without changes to `compileTime` that would either break other code (making it not eagerly fold by default) or still require a change in stew (adding an option to disable the eager folding). Alternatively we could also make the eager folding opt-in only for generic compileTime procs so that #22022 breaks nothing whatsoever, but a universal solution would be better. Edit: Done in #24230 via experimental switch (cherry picked from commit ea9811a)
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. (cherry picked from commit 1bebc23)
templates/macros use no expected types when return types are specified (
#24298) fixes #24296 fixes #24295 Templates use `expectedType` for type inference. It's justified that when templates don't have an actual return type, i.e., `untyped` etc. When the return type of templates is specified, we should not infer the type ```nim template g(): string = "" let c: cstring = g() ``` In this example, it is not reasonable to annotate the templates expression with the `cstring` type before the `fitNode` check with its specified return type. (cherry picked from commit 80e6b35)
wrap fields iterations in if true scope [backport] (#24343)
fixes #24338 When unrolling each iteration of a `fields` iterator, the compiler only opens a new scope for semchecking, but doesn't generate a node that signals to the codegen that a new scope should be created. This causes issues for reused template instantiations that reuse variable symbols between each iteration, which causes the codegen to generate multiple declarations for them in the same scope (regardless of `inject` or `gensym`). To fix this, we wrap the unrolled iterations in an `if true: body` node, which both opens a new scope and doesn't interfere with `break`. (cherry picked from commit ca5df9a)
fixes #24258; compiler crash on len of varargs[untyped] (#24307)
fixes #24359; VM problem: dest register is not set with const-bound p…
fixes addr/hiddenAddr in strictdefs (#23477)
(cherry picked from commit 9b37829) (cherry picked from commit 744b241e4b7cb8c8d9e21e8a7f078d17d9ef90d4)
fixes #22389; fixes #19840; don't fold paths containing addr (#23807)
shallow fold prevention for addr, nkHiddenAddr (#24322)
fixes #24305, refs #23807 Since #23014 `nkHiddenAddr` is produced to fast assign array elements in iterators. However the array access inside this `nkHiddenAddr` can get folded at compile time, generating invalid code. In #23807, compile time folding of regular `addr` expressions was changed to be prevented in `transf` but `nkHiddenAddr` was not updated alongside it. The method for preventing folding in `addr` in #23807 was also faulty, it should only trigger on the immediate child node of the address rather than all nodes nested inside it. This caused a regression as outlined in [this comment](#24322 (comment)). To fix both issues, `addr` and `nkHiddenAddr` now both shallowly prevent constant folding for their immediate children. (cherry picked from commit 52cf7df) (cherry picked from commit 7ad7ee03e5c0adb6832cbae10a62de7b68ef6fa5)