Commit Graph

205 Commits

Author SHA1 Message Date
ringabout
55636a2913 fixes #14255; Crash in compiler when using system.any by accident. (#21562)
fixes #14255; Crash in compiler when using system.any by accident.
2023-03-23 16:10:14 +01:00
ringabout
b5ee81fd23 fix #18977; disallow change branch of an object variant in ORC (#21526)
* 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
2023-03-16 16:06:26 +01:00
ringabout
6552a27ec1 fixes #19857; Exception raised in closure may be "skipped" in ORC (#21530)
fixes #19857; Exception raised in closure may be "skipped"
2023-03-16 21:07:54 +08:00
ringabout
0319824322 fixes #21023; Segfault when mixing seqs, orc, variants and futures (#21497)
* fixes #21023; Segfault when mixing seqs, orc, variants and futures

* fixes none of the branches were explicitly selected

* add one more test

* one more test
2023-03-10 09:28:51 +01:00
Andreas Rumpf
50baf21eac fixes #20422; emit nimPrepareStrMutationV2 for toOpenArray to keep th… (#21459)
fixes #20422; emit nimPrepareStrMutationV2 for toOpenArray to keep the abstraction of mutable strings which have immutable string literals
2023-03-02 08:36:02 +01:00
ringabout
a137e50150 fixes #19291; implements wasMoved hook (#21303)
* 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
2023-03-02 05:29:40 +01:00
ringabout
38f876dd48 fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now 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
2023-02-22 20:34:20 +01:00
ringabout
4b63ac4b87 fixes #21171; dynamic acyclic refs need to use dyn decRef (#21184)
* fixes #21171; dyn destructors for acyclic inherited  refs

* add a test

* Update compiler/liftdestructors.nim
2022-12-28 16:23:37 +01:00
Bung
8054be6e52 fix #20588 (#21104) 2022-12-15 16:12:17 +01:00
ringabout
b83bd282dc fixes #20954; bounchecks for len(toOpenArray()) [backport] (#20956)
* bounchecks for len(toOpenArray())

* add a testcase
2022-12-05 22:27:18 +01:00
ringabout
e03a178bff rename std/threads to std/typedthreads (#20850)
* rename `std/threads` to `std/oldthreads`

* fixes tests

* rename to `typedthreads`

* changelog
2022-11-16 16:35:20 +01:00
ringabout
3d692d08f7 fixes a long-standing ARC bug (#20849)
* fixes an ARC bug

* add a testcase
2022-11-16 07:36:14 +01:00
Derek 呆
6007a40eac support UncheckedArray[T] in repr_v2.nim (#20816) 2022-11-11 19:31:59 +01:00
Bung
82e99f2332 fix topt_no_cursor.nim (#20791) 2022-11-09 15:52:44 -05:00
Bung
fdc8dd4128 Arc global (#20768)
* temp

* unsure

* fix condition

* port macro arc runable examples to one file

* trigger doc ci

* fix

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2022-11-06 11:47:35 +01:00
ringabout
afd4e22f76 Revert "fix arc global variable issues" (#20764)
* Revert "fix arc global variable issues (#20759)"

This reverts commit a3d32a4176.

* trigger documentation builds
2022-11-05 22:47:12 +08:00
Bung
a3d32a4176 fix arc global variable issues (#20759)
* temp

* unsure
2022-11-05 12:22:16 +01:00
ringabout
e1ddd2d524 put std/threads under the umbrella of nimPreviewSlimSystem (#20711)
* put `std/threads` under the umbrella of `nimPreviewSlimSystem`

* add changelog

* fixes tests

* fixes tests again

* fixes tests
2022-10-31 06:36:50 +01:00
Andreas Rumpf
81087c949f fixes #20572 (#20585)
* fixes #20572

* added a test case
2022-10-17 23:48:51 +02:00
ringabout
5602183234 'lock levels' are deprecated, now a noop (#20539)
* 'lock levels' are deprecated, now a noop

* fixes tests
2022-10-11 09:17:09 +02:00
ringabout
114acff98d closes #9401; add testcase (#20507) 2022-10-06 13:51:42 +08:00
ringabout
a600dfa5b7 closes #11267; closes #11259; closes #11085; add testcases (#20505)
* closes #11267; add testcase

* closes #11259

* closes #11085
2022-10-06 02:30:10 +08:00
ringabout
3e2b30879c fixes #19231; newFinalize doesn't work with ORC (#20291)
* fixes #19231; newFinalize doesn't work with ORC

first make it pass tests

* remove the tables dep

creates a binding for finalized procs in order to handle the same symbols. It used to wrongly generat a new symbol id for the same symbol as the encountered one before

* refactor and revert #14257

* de indentation

* fixes tests; uses instantiated types
2022-10-05 10:35:40 +02:00
ringabout
0f5ad49971 [ARC] fixes #18645; C Compiler error when initializing {.global.} with a block (#19953)
* fixes #18645; C Compiler error when initializing {.global.} with a block:

* arguably cleaner solution

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
Co-authored-by: Araq <rumpf_a@web.de>
2022-10-03 16:12:23 +02:00
ringabout
81e7811e01 fixes nim check with orc (#20456)
* fixes nim check with orc

* fixes tests

* add tests

* fixes tests

* Update tests/arc/t20456.nim
2022-10-02 06:44:10 +02:00
metagn
0b1650576c move widestrs out of system (#20462)
* move widestrs out of system

* fix osproc
2022-10-01 22:35:09 +02:00
Andreas Rumpf
8d47bf1822 new move analyser2 (#20471)
* 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>
2022-10-01 16:46:51 +02:00
konsumlamm
18cea8e9bd Update message for checking cast (#20145)
* Update message for checking `cast`

* Update error messages in tests
2022-09-28 13:59:27 +02:00
ringabout
fe8feb46c6 fixes #19457 seqs are not properly updated in loop with ARC/ORC (#19922)
* test CI

* fixes #19457

* add comments

Co-authored-by: sandytypical <43030857+xflywind@users.noreply.github.com>
2022-09-28 13:12:08 +02:00
ringabout
80e739f2bf fixes #19401; fixes #19402; rework Forward declaration and finalizer for ORC (#20295)
* fixes #19401; fixes #19402; rework Forward declaration and finalizer for ORC

* add more tests

* give it a name

* make more tests

* fixes tests

* hidden addr for cpp

* move code to a function
2022-09-27 20:07:26 +02:00
Antonis Geralis
7c85b500df Add testcase for bug #20305 (#20323)
* add testcase for bug #20305

* Update tcaseobj.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-09-13 19:10:08 +08:00
Andreas Rumpf
6bf21e7b3d fixes #19724; don't be aggressive when you infer sink parameters (#20314)
* fixes #19724; don't be aggressive when you infer sink parameters

* better logic and updated tests

* wip

* fixes tests (#20330)

* restore tests

* try splitPath

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
2022-09-12 00:58:29 +02:00
ringabout
bbbfde7341 fixes #20303; wasMoved expressions with side effects for ORC (#20307) [backport]
fixes #20303; wasMoved expressions with side effects
2022-09-08 08:07:28 +02:00
havardjohn
23e0160af2 Add improved Windows UNC path support in std/os (#20281)
* Add improved Windows UNC path support in std/os

Original issue: `std/os.createDir` tries to create every component of
the given path as a directory. The problem is that `createDir`
interprets every backslash/slash as a path separator. For a UNC path
this is incorrect. E.g. one UNC form is `\\Server\Volume\Path`. It's an
error to create the `\\Server` directory, as well as creating
`\\Server\Volume`.

Add `ntpath.nim` module with `splitDrive` proc. This implements UNC path
parsing as implemented in the Python `ntpath.py` module. The following
UNC forms are supported:

* `\\Server\Volume\Path`
* `\\?\Volume\Path`
* `\\?\UNC\Server\Volume\Path`

Improves support for UNC paths in various procs in `std/os`:
---

* pathnorm.addNormalizePath
  * Issue: This had incomplete support for UNC paths
    * The UNC prefix (first 2 characters of a UNC path) was assumed to
      be exactly `\\`, but it can be `//` and `\/`, etc. as well
    * Also, the UNC prefix must be normalized to the `dirSep` argument
      of `addNormalizePath`
  * Resolution: Changed to account for different UNC prefixes, and
    normalizing the prefixes according to `dirSep`
    * Affected procs that get tests: `relativePath`, `joinPath`
  * Issue: The server/volume part of UNC paths can be stripped when
    normalizing `..` path components
    * This error should be negligable, so ignoring this
* splitPath
  * Now make sure the UNC drive is not split; return the UNC drive as
    `head` if the UNC drive is the only component of the path
  * Consequently fixes `extractFilename`, `lastPathPart`
* parentDir / `/../`
  * Strip away drive before working on the path, prepending the drive
    after all work is done - prevents stripping UNC components
  * Return empty string if drive component is the only component; this
    is the behavior for POSIX paths as well
  * Alternative implementation: Just call something like
    `pathnorm.normalizePath(path & "/..")` for the whole proc - maybe
    too big of a change
* tailDir
  * If drive is present in path, just split that from path and return
    path
* parentDirs iterator
  * Uses `parentDir` for going backwards
  * When going forwards, first `splitDrive`, yield the drive field, and
    then iterate over path field as normal
* splitFile
  * Make sure path parsing stops at end of drive component
* createDir
  * Fixed by skipping drive part before creating directories
  * Alternative implementation: use `parentDirs` iterator instead of
    iterating over characters
    * Consequence is that it will try to create the root directory
* isRootDir
  * Changed to treat UNC drive alone as root (e.g. "//?/c:" is root)
  * This change prevents the empty string being yielded by the
    `parentDirs` iterator with `fromRoot = false`
* Internal `sameRoot`
  * The "root" refers to the drive, so `splitDrive` can be used here

This adds UNC path support to all procs that could use it in std/os. I
don't think any more work has to be done to support UNC paths. For the
future, I believe the path handling code can be refactored due to
duplicate code. There are multiple ways of manipulating paths, such as
manually searching string for path separator and also having a path
normalizer (pathnorm.nim). If all path manipulation used `pathnorm.nim`,
and path component splitting used `parentDirs` iterator, then a lot of
code could be removed.

Tests
---

Added test file for `pathnorm.nim` and `ntpath.nim`.
`pathnorm.normalizePath` has no tests, so I'm adding a few unit tests.
`ntpath.nim` contains tests copied from Python's test suite.

Added integration tests to `tos.nim` that tests UNC paths.

Removed incorrect `relativePath` runnableExamples from being tested on Windows:
---

`relativePath("/Users///me/bar//z.nim", "//Users/", '/') == "me/bar/z.nim"`

This is incorrect on Windows because the `/` and `//` are not the same
root. `/` (or `\`) is expanded to the drive in the current working
directory (e.g. `C:\`). `//` (or `\\`), however, are the first two
characters of a UNC path. The following holds true for normal Windows
installations:

* `dirExists("/Users") != dirExists("//Users")`
* `dirExists("\\Users") != dirExists("\\\\Users")`

Fixes #19103

Questions:
---

* Should the `splitDrive` proc be in `os.nim` instead with copyright
  notice above the proc?
* Is it fine to put most of the new tests into the `runnableExamples`
  section of the procs in std/os?

* [skipci] Apply suggestions from code review

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* [skip ci] Update lib/pure/os.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Move runnableExamples tests in os.nim to tos.nim

* tests/topt_no_cursor: Change from using splitFile to splitDrive

`splitFile` can no longer be used in the test, because it generates
different ARC code on Windows and Linux. This replaces `splitFile` with
`splitDrive`, because it generates same ARC code on Windows and Linux,
and returns a tuple. I assume the test wants a proc that returns a
tuple.

* Drop copyright attribute to Python

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-09-03 20:47:09 -04:00
quantimnot
6289b002b6 [Testament] Extend and document message testing aids (#19996)
* [Testament] Extend and document message testing aids

* Enable inline msgs when not reject action.
Eliminates the pain of changing the line and column numbers in `nimout`
or `output` while making changes to the test.
* Enable using inline msgs and nimout together.
Allows ease of inline msgs for the test as well as testing msgs from
other modules.
* Add path separator and test filename variable interpolation in
msgs.
Eases handling path separators in the msgs.
* Add some documentation.

* Fixed lots of broken tests

* Fixed more broken tests

* Support multiple inline messages per a line

* Fix a broken test

* Revert variable substitution in `output`

* Remove uneeded params

* Update doc/testament.md

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Update testament/specs.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Update testament/specs.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Fix indentation

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-09-01 17:52:13 +02:00
flywind
bcff13debc dec inLoop after exiting the while scope in computeLiveRanges [backport] (#19918)
* dec inLoop after exiting the while scope in computeLiveRanges

* add testcase
2022-06-29 22:37:24 +08:00
flywind
1972005439 fix #19862; make widestrs consistent between refc and orc (#19874) [backport]
fix #19862; make widestrs consistent in refc and orc
2022-06-09 16:51:17 +02:00
flywind
efaa6777a4 fix #19435; don't create TypeBoundOps for tyOpenArray, tyVarargs [backport: 1.6] (#19723)
* fix #19435; openArray wronyly registers typebounds

* add testcase

* don't create TypeBoundOps for tyOpenArray, tyVarargs
2022-04-25 11:07:55 +02:00
flywind
a262a87bbe [add testcase] arc problems with recursive types (#19456)
* [add testcase] arc problems with recursive types

close #9650

* do test

* expand

* Update tests/arc/t9650.nim
2022-03-23 21:07:05 +01:00
flywind
b936bfd01a fix #16458; make useNimRtl compile for --gc:orc (#19512)
* fix #16458; make useNimRtl compile for --gc:orc/arc

* fix tests
2022-02-11 11:16:27 +01:00
flywind
27e548140b don't use a temp for addr [backport: 1.6] (#19503)
* don't use a temp for addr

fix #19497

* Update compiler/ccgcalls.nim

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* add a test

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2022-02-08 08:34:44 +01:00
flywind
d102b2f54c deprecate unsafeAddr; extend addr (#19373)
* 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 ab83c99c50.

* 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>
2022-01-16 11:08:38 +01:00
flywind
9df195ef58 style usages part one (openarray => openArray) (#19321)
* style usages (openArray)

* revert doc changes
2022-01-04 13:29:50 +01:00
Andreas Rumpf
32d4bf3525 fixes an old ARC bug: the produced copy/sink operations don't copy the hidden type field for objects with enabled inheritance; fixes #19205 [backport:1.6] (#19232) 2021-12-09 22:23:16 +01:00
flywind
2f730afe9e fix #18410 (Errors initializing an object of RootObj with the C++ backend) [backport] (#18836)
* fix #18410

* one line comment

* typo

* typo

* cover cpp
2021-10-31 06:22:00 +01:00
Derek 呆
f755e452d2 fix #18971 (#19070) [backport:1.6]
since the example code return value from global variable, instead
of first argument, the `n.len` is 1 which causes compiler crashes.
2021-10-29 19:55:48 +02:00
flywind
4b764f4c7c close #17319; add testcase (#18934) 2021-10-01 16:19:02 +08:00
flywind
677969f6ea alternative to #18918 (#18927)
* fix #16558

* add testcase
2021-09-30 16:57:06 +02:00
flywind
bf1700bab1 add testcase for #7308 (#18849) 2021-09-14 19:39:55 +02:00
Andreas Rumpf
e8dad482a3 fixes #16246 (#18800) 2021-09-04 15:57:16 +02:00