summary refs log tree commit diff stats
path: root/tests/destructor
Commit message (Collapse)AuthorAgeFilesLines
* Optimize closure iterator locals (#23787)Yuriy Glukhov2024-07-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pr redefines the relation between lambda lifting and closureiter transformation. Key takeaways: - Lambdalifting now has less distinction between closureiters and regular closures. Namely instead of lifting _all_ closureiter variables, it lifts only those variables it would also lift for simple closure, i.e. those not owned by the closure. - It is now closureiter transformation's responsibility to lift all the locals that need lifting and are not lifted by lambdalifting. So now we lift only those locals that appear in more than one state. The rest remains on stack, yay! - Closureiter transformation always relies on the closure env param created by lambdalifting. Special care taken to make lambdalifting create it even in cases when it's "too early" to lift. - Environments created by lambdalifting will contain `:state` only for closureiters, whereas previously any closure env contained it. IMO this is a more reasonable approach as it simplifies not only lambdalifting, but transf too (e.g. freshVarsForClosureIters is now gone for good). I tried to organize the changes logically by commits, so it might be easier to review this on per commit basis. Some ugliness: - Adding lifting to closureiters transformation I had to repeat this matching of `return result = value` node. I tried to understand why it is needed, but that was just another rabbit hole, so I left it for another time. @Araq your input is welcome. - In the last commit I've reused currently undocumented `liftLocals` pragma for symbols so that closureiter transformation will forcefully lift those even if they don't require lifting otherwise. This is needed for [yasync](https://github.com/yglukhov/yasync) or else it will be very sad. Overall I'm quite happy with the results, I'm seeing some noticeable code size reductions in my projects. Heavy closureiter/async users, please give it a go.
* [backport] fixes #23748; do not skip materializing temporaries for proc ↵Alexander Kernozhitsky2024-06-301-0/+31
| | | | | arguments (#23769) fixes #23748
* fixes #22398; [backport] (#23704)Andreas Rumpf2024-06-101-0/+19
|
* fixes #23552; Invalid codegen when trying to mannualy delete distinct seq ↵ringabout2024-05-081-0/+8
| | | | | (#23558) fixes #23552
* fixes #23524; global variables cannot be analysed when injecting `move` (#23529)ringabout2024-04-241-17/+18
| | | | | | | | | | | | fixes #23524 ```nim proc isAnalysableFieldAccess*(orig: PNode; owner: PSym): bool = ... result = n.kind == nkSym and n.sym.owner == owner and {sfGlobal, sfThread, sfCursor} * n.sym.flags == {} and (n.sym.kind != skParam or isSinkParam(n.sym)) ``` In `isAnalysableFieldAccess`, globals, cursors are already rejected
* fixes sink regression for ORC; ref #23354 (#23359)ringabout2024-03-031-0/+16
| | | | | | | | | ref #23354 The new move analyzer requires types that have the tfAsgn flag (otherwise `lastRead` will return true); tfAsgn is included when the destructor is not trival. But it should consider the assignement for objects in this case because objects might have a trival destructors but it's the assignement that matters when it is passed to sink parameters.
* fixes #22286; enforce Non-var T destructors by `nimPreviewNonVarDestructor` ↵ringabout2023-11-253-14/+39
| | | | | | | | | | | | | | | | | | (#22975) fixes #22286 ref https://forum.nim-lang.org/t/10642 For backwards compatibilities, we might need to keep the changes under a preview compiler flag. Let's see how many packags it break. **TODO** in the following PRs - [ ] Turn the `var T` destructors warning into an error with `nimPreviewNonVarDestructor` --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes move sideeffects issues [backport] (#22439)ringabout2023-08-101-0/+18
| | | | | | | * fixes move sideeffects issues [backport] * fix openarray * fixes openarray
* fixes #22197; Distinct ref objects + destructor cause C++ codegen error (#22207)ringabout2023-07-021-1/+26
|
* adds =destroy T support for strings and seqs (#22167)ringabout2023-06-271-6/+6
| | | | | | | * adds =destroy T support for strings and seqs * fixes system * fixes tests
* allow destructors to accept non var parameters; deprecate `proc =destroy(x: ↵ringabout2023-06-211-0/+195
| | | | | | | | | | var T)` (#22130) * make destructors accept non var parameters * define nimAllowNonVarDestructor * add a test case and a changelog * update documentation and error messages * deprecate destructors taking 'var T'
* make `move` use `=wasMoved` internally (#22032)ringabout2023-06-091-0/+14
| | | | | | | | | | | | | * make `move` use `=wasMoved` internally * fixes tests * fixes spawn finally * fixes views * rename to internalMove * add a test case
* infer error for `=dup` if there is a custom `=copy` error hook (#22004)ringabout2023-06-051-2/+2
|
* lift the `=dup` hook (#21903)ringabout2023-06-025-18/+25
| | | | | | * fixes tests again * remove helper functions * fixes closures, owned refs * final cleanup
* fix #18977; disallow change branch of an object variant in ORC (#21526)ringabout2023-03-161-1/+2
| | | | | | | | | | | * fix #18977 disallow change branch of an object variant in ORC * check errors for goto exception * fixes conditions * fixes tests * add a test case for #18977
* fixes #19291; implements `wasMoved` hook (#21303)ringabout2023-03-022-6/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #19291; implements `wasMoved` hook * basics * checkpoint * finish `wasMoved` * add a test for #19291 * add documentation and changelog * work `attachedWasMoved` with generics * fixes optimizer * register `=wasMoved` * handle wasMoved magcis * check another round * some patches * try `op == nil` * nicer * generate `wasMoved` before `destroy` * try again * fixes tests * default wasMoved * Update tests/destructor/tv2_cast.nim * Update tests/destructor/tv2_cast.nim * Update tests/arc/topt_refcursors.nim
* fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now ↵ringabout2023-02-221-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parses the whole module at one time (#21379) * fixes #19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes #11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
* fixes a severe bug of testament (#20832)ringabout2022-11-171-0/+1
| | | | | | | | | | | | | | | | | | | * test azure * use exit 1 * try again * use useSysAssert * disable i386 * use refc for tlsEmulation on i386 * use refc * disable i386 Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* new move analyser2 (#20471)Andreas Rumpf2022-10-016-12/+11
| | | | | | | | * produce better code for closure environment creation * new 'first write' analysis; * scope based move analyser * code cleanup Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* defaults to ORC (#19972)ringabout2022-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * defaults to Orc * bootstrap using refc * use gc * init orc defines * unregister orc * fix gc * fix commands * add prepareMutation for orc * enable deepcopy for orc * prepareMutation * more fixes * some cases * bug #20081 * partial fixes * partial fixes * fixes command line * more fixes * build Nim with refc * use gc * more fixes * rstore * orc doesn't support threadpool * more shallowCopy * more fixes * fixes unsafeNew * workarounds * small * more fixes * fixes some megatest * tcodegenbugs1 refc * fxies megatest * build nimble with refc * workaround tensordsl tests * replace shallowCopy with move * fixes action * workaround * add todo * fixes important packages * unpublic unregisterArcOrc * fixes cpp * enable windows Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* remove {.this.} pragma, deprecated since 0.19 (#20201)metagn2022-08-231-11/+9
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Add use of Windows Wide CRT API for env. vars (#20084)havardjohn2022-08-201-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add use of Windows Wide CRT API for env. vars Replaces use of CRT API `getenv` and `putenv` with respectively `_wgetenv` and `_wputenv`. Motivation is to reliably convert environment variables to UTF-8, and the wide API is best there, because it's reliably UTF-16. Changed the hack in `lib/std/private/win_setenv.nim` by switching the order of the Unicode and MBCS environment update; Unicode first, MBCS second. Because `_wgetenv`/`_wputenv` is now used, the Unicode environment will be initialized, so it should always be updated. Stop updating MBCS environment with the name of `getEnv`. It's not necessarily true that MBCS encoding and the `string` encoding is the same. Instead convert UTF-16 to current Windows code page with `wcstombs`, and use that string to update MBCS. Fixes regression in `6b3c77e` that caused `std/envvars.getEnv` or `std/os.getEnv` on Windows to return non-UTF-8 encoded strings. Add tests that test environment variables with Unicode characters in their name or value. * Fix test issues Fixes * `nim cpp` didn't compile the tests * Nimscript import of `tosenv.nim` from `test_nimscript.nims` failed with "cannot importc" * Fix missing error check on `wcstombs` * Fix ANSI testing errors * Separate ANSI-related testing to their own tests, and only executing them if running process has a specific code page * Setting locale with `setlocale` was not reliable and didn't work on certain machines * Add handling of a "no character representation" error in second `wcstombs` call * tests/newruntime_misc: Increment allocCount Increments overall allocations in `tnewruntime_misc` test. This is because `getEnv` now does an additional allocation: allocation of the UTF-16 string used as parameter to `c_wgetenv`. * Revert "tests/newruntime_misc: Increment allocCount" This reverts commit 4d4fe8bd3edb1bfc6d600f247af797c7552f5477. * tests/newruntime_misc: Increment allocCount on Windows Increments overall allocations in `tnewruntime_misc` test for Windows. This is because `getEnv` on Windows now does an additional allocation: allocation of the UTF-16 string used as parameter to `c_wgetenv`. * Refactor, adding suggestions from code review Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Document, adding suggestions Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* default threads on (#19368)flywind2022-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * default threads on * make rst gcsafe * ignore threads option for nimscript * threads off * use createShared for threads * test without threads * avr threds off * avr threads off * async threads off * threads off * fix ci * restore option * make CI pleased * fix ic tests * Update config.nims * add changelog * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* Fix global destructor injection for JS backend (#19797)quantimnot2022-05-231-1/+2
| | | | | | | | | | | | | | * Fix global destructor injection for JS backend * Moved global destructors injection before the final call to transform and generate JS code. It had previously been after and thus not no JS was generated for them. * Added some internal documentation of `jsgen`. * Enable a current destructor test to cover the JS backend as well. * Fixes the JS aspect of #17237. * Fixed global destructor injection order for JS backend Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* deprecate unsafeAddr; extend addr (#19373)flywind2022-01-165-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | * deprecate unsafeAddr; extend addr addr is now available for all addressable locations, unsafeAddr is deprecated and become an alias for addr * follow @Vindaar's advice * change the signature of addr * unsafeAddr => addr (stdlib) * Update changelog.md * unsafeAddr => addr (tests) * Revert "unsafeAddr => addr (stdlib)" This reverts commit ab83c99c507048a8396e636bf22d55fdd84d7d1c. * doc changes; thanks to @konsumlamm Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* style usages part one (openarray => openArray) (#19321)flywind2022-01-041-1/+1
| | | | | * style usages (openArray) * revert doc changes
* Remove tracking of environment from osenv.nim v2 (#18575)Timothee Cour2021-07-291-1/+1
| | | | | | | | | | | | | * Remove unnecessary environment tracking * try to fix windows * fix delEnv * make putEnv work on windows even with empty values; improve tests: add tests, add js, vm testing * [skip ci] fix changelog Co-authored-by: Caden Haustein <code@brightlysalty.33mail.com>
* fixes #18130 (#18407)Andreas Rumpf2021-07-011-16/+71
|
* Add some tests (#18333)Antonis Geralis2021-06-231-2/+70
|
* document macros.unpackVarargs (#18106)Timothee Cour2021-05-311-0/+1
| | | | | | | * deprecate macros.unpackVarargs * un-deprecate unpackVarargs and add docs+runnableExamples * update examples + tests with varargs[typed]
* Remove confusing <//> (#17830)flywind2021-04-261-1/+6
|
* close #17636 (#17643)flywind2021-04-061-2/+2
|
* Fixes #17450 (#17477)Clyybber2021-03-231-1/+12
| | | | | * Fixes #17450 * Add missing test output
* Revert "Fixes #17450 (#17474)" (#17476)Clyybber2021-03-231-12/+1
| | | This reverts commit 5f0c52048970cb7449937bd19191638c9e9f0c8f.
* Fixes #17450 (#17474)Clyybber2021-03-231-1/+12
| | | | | * Fixes #17450 * Add missing test output
* Revert "Revert "close #16607 add testcase (#17317)" (#17336)" (#17347)Clyybber2021-03-121-0/+24
| | | This reverts commit 3ce27511adac12785b51ecc33dc9d2a2fcd2f0b8.
* Revert "close #16607 add testcase (#17317)" (#17336)Clyybber2021-03-111-24/+0
| | | This reverts commit 1655103d83433aa3d4c607c7477281d137d7c794.
* close #9440 add testcase (#17316)flywind2021-03-091-0/+52
|
* close #16607 add testcase (#17317)flywind2021-03-091-0/+24
|
* deprecate newruntime (#17245)flywind2021-03-049-9/+9
| | | | | | * deprecate newruntime * tests * Update compiler/commands.nim
* fixes #17198, DFA failure on large case stmts (#17210)Saem Ghani2021-03-021-0/+32
| | | | | | This alters the DFA control flow graph generation for case statments. Gotos are now generated as a chained link, this ensures that evaluation of variant branches collapses as early as possible, without hitting the 2k call limit.
* close #5342 add testcase (#17230)flywind2021-03-021-0/+23
| | | | | | | | | * remove unnecessary when statement * remove outdated codes * close #5342 add testcase * update the example
* remove all uses of condsyms symbols defined prior to bootstrap nim 0.20.0 ↵Timothee Cour2021-02-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#16918) * nimNoArrayToCstringConversion deadcode * nimbabel deadcode * nimHasalignOf deadcode * nimvarargstyped deadcode * nimhygiene deadcode * nimNewTypedesc deadcode * nimlocks deadcode * nimHasCppDefine deadcode * nimHasRunnableExamples deadcode * nimHasNilChecks deadcode * nimSymKind deadcode * minor macros refactoring * nimVmEqIdent deadcode * nimNoNil deadcode * nimNoZeroTerminator deadcode * nimHasSymOwnerInMacro deadcode * nimVmExportFixed deadcode * nimNewRuntime deadcode * nimAshr deadcode * nimUncheckedArrayTyp deadcode * nimHasTypeof deadcode * nimErrorProcCanHaveBody deadcode * nimHasHotCodeReloading deadcode * nimHasSignatureHashInMacro deadcode * nimHasDefault deadcode * nimMacrosSizealignof deadcode
* don't introduce 'dispose', use '=dispose', fixes #17003 [backport:1.4] (#17062)Andreas Rumpf2021-02-171-1/+1
|
* use doAssert in tests (#16486)flywind2020-12-281-8/+8
|
* fixes #16365 [backport] (#16381)Andreas Rumpf2020-12-171-1/+31
|
* testament: error instead of silently ignore invalid targets; remove ↵Timothee Cour2020-12-142-2/+2
| | | | | | | | | | | pointless alias target vs targets; document matrix; DRY (#16343) * testament: error instead of silently ignore invalid targets * s/target/targets/ * fix test; refs #16344 * address comments * Update testament/specs.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* testament spec: remove errmsg alias of errormsg (#16188)Timothee Cour2020-11-291-1/+1
|
* make megatest consistent with unjoined tests wrt newlines, honor newlines in ↵Timothee Cour2020-11-281-1/+1
| | | | | | | output spec (#16151) * fix megatest newlines * still allow missing trailing newline for now but in a more strict way than before
* fix #15825 (#15894)cooldome2020-11-091-0/+11
| | | | | * fix #15825 * better fix