Commit Graph

125 Commits

Author SHA1 Message Date
Mark Spanbroek 3dcf21491d `without` with error variable works for any Result type 2024-05-29 12:45:40 +02:00
Mark Spanbroek 82d90b67bc version 0.10.15 2024-04-20 08:08:31 +02:00
Mark Spanbroek b098ae696a Workaround for Nim gensym bug
Occasionally different `evaluated` symbols would be
gensymmed to the same symbol.
2024-04-20 08:07:28 +02:00
Mark Spanbroek 83ae4a6409 version 0.10.14 2024-03-10 12:14:59 +01:00
Mark Spanbroek 57e467b8b0 Fix: `without` should work when `$` has side effects
It's ok to use unsafeError in bindFailed, because we've
already checked that the result contains an error.
2024-03-10 12:13:25 +01:00
Mark Spanbroek 47692e0d92 version 0.10.13 2024-01-09 16:57:24 +01:00
Mark Spanbroek 6ef525cfe2 Reference types are handled by `without` statement with error 2024-01-09 16:52:39 +01:00
Mark Spanbroek 43e7deb827 Fix BareExcept warnings 2024-01-09 16:46:01 +01:00
Mark Spanbroek 4a74d65e17 Mark generated error variable explicitly as {.gensym.}
Co-Authored-By: Jaremy Creechley <creechley@gmail.com>
2024-01-09 16:45:32 +01:00
Mark Spanbroek 672248f431 Get rid of trick with type parameter 2024-01-09 16:45:32 +01:00
Mark Spanbroek d463d491cc Handle bind (=?) errors in `without` statements differently
Keeps track of the current error variable at compile time,
instead of using a pointer to the error variable at runtime.

Employs a trick with an unused type parameter to ensure that
invocations of the bindFailed() macro are expanded after
captureBindError() is expanded.
2024-01-09 16:45:32 +01:00
Tomasz Bekas 1f0afff48b
Support for .?[] operator on openArrays (#52)
* Support for .?[] operator on openArrays

* Operator .?[] evaluates openArray expression only once

* Fix for Nim 1.2.x

---------

Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
2023-11-20 14:58:49 +01:00
Mark Spanbroek 2dd6b6b220 version 0.10.12 2023-11-14 10:57:03 +01:00
Nickolay Bukreyev 0f095d6b7c Overload `toOption` for `Result`
Necessary for the `=?` operator to work.
2023-11-14 10:52:45 +01:00
Nickolay Bukreyev cdf639c4ea Support binding closure iterators (except on Nim == 2.0)
See nim-lang/Nim#22932.
2023-11-14 10:52:45 +01:00
Nickolay Bukreyev fe47a19825 Create identifiers with `genSym` 2023-11-14 10:52:45 +01:00
Nickolay Bukreyev 440debc7c3 Accept only optional and reference types as RHS of `=?`
The fact that `option(x)` works for non-reference types (being an alias
for `some`) is an stdlib's design mistake that bites us here.
2023-11-14 10:52:45 +01:00
Mark Spanbroek c2a08bd703 version 0.10.11 2023-11-08 10:14:25 +01:00
Mark Spanbroek 52e11f2011 Fix compilation issue with Nim 1.6.16
Workaround for https://github.com/nim-lang/Nim/issues/22897
2023-11-08 10:09:10 +01:00
Mark Spanbroek af4f194597 Fix tests for Nim < 2.0 2023-08-30 11:02:37 +02:00
Mark Spanbroek 5c8d422ac8 fix error binding in `without` statement on multiple threads 2023-08-30 11:02:37 +02:00
Mark Spanbroek e56cf86c4a Indexing of strings and sequences should not catch Defect
Catching a Defect does not always work, depending on how
it's compiled.
2023-08-03 15:17:40 +02:00
Tomasz Bekas 416b6dd566 Support seq indexing 2023-08-03 12:56:12 +02:00
Mark Spanbroek 08581f5efd Run CI on Nim 1.2, 1.4, 1.6 and 2.0 2023-08-03 09:41:43 +02:00
Mark Spanbroek 9af4ce1ca1 Better compilation error when calling `without` with wrong parameter 2023-08-03 09:41:43 +02:00
Mark Spanbroek 1569ef4526 Fix tests for stew with Nim < 1.6
Stew now requires a Nim >= 1.6, so this disables
testing stew with earlier Nim versions.
2023-07-28 09:57:51 +02:00
Mark Spanbroek b3cf35ac45 version 0.10.10 2023-07-03 11:17:51 +02:00
Mark Spanbroek 3bce3088a7 Use root configuration when running tests 2023-07-03 11:16:56 +02:00
Mark Spanbroek ffe0faa3bb Only enable --styleCheck:usages on Nim versions that support it 2023-07-03 11:16:56 +02:00
Mark Spanbroek 0d7ce8efde Provide conversion to string `$` for Results 2023-06-26 10:04:02 +02:00
Mark Spanbroek 58c10fb333 version 0.10.9 2023-06-26 10:02:25 +02:00
Mark Spanbroek 8daae27089 Do not edit AST nodes, make a copy first
Fixes error "typechecked nodes may not be modified"
2023-06-26 09:59:14 +02:00
Mark Spanbroek b18444a6d0 Support renamed 'results' library 2023-06-05 17:26:46 +02:00
Mark Spanbroek f957dd59d6 Fix tests on Nim 1.6.12
Ignore the nimble.lock at the root level when running tests
2023-06-05 17:26:46 +02:00
Mark Spanbroek 6cbbda7e4d version 0.10.8 2023-02-14 09:31:58 +01:00
Eric Mastro 096ca864b0
tuple binding and unpacking support (#29)
* tuple binding and unpacking support

* support tuple binding in nim < 1.6

* Use ? instead of Option[] in tests

* Test binding of optional tuple, not just tuple

* Add tests for tuple unpacking of Result

* Remove unused import

* Rearrange tuple binding code

Introduce separate proc for creation of unpacking
statement.

Use `quote do` to make code as similar as possible
to the `bindLet` and `bindVar` templates.

* Add tests for failed tuple bindings

---------

Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
2023-02-14 09:56:32 +11:00
Mark Spanbroek 1dcef4b302 version 0.10.7 2022-10-20 12:13:43 +02:00
Mark Spanbroek f78bdd9d58 Fix redefinition of 'T`gensymXX' error
In rare instances, the Nim compiler will generate the same
symbol more than once. Adding a block works around this issue.

Reproducing this behavior in a unit test has proved elusive.
2022-10-20 05:10:44 -05:00
Mark Spanbroek 30e4184a99 version 0.10.6 2022-09-28 11:37:36 +02:00
Mark Spanbroek 4d631b1ba9 Fix: ensure that options and results are only evaluated once 2022-09-28 11:36:28 +02:00
Mark Spanbroek 82408a5ca2 version 0.10.5 2022-08-10 13:39:00 +02:00
Mark Spanbroek cbdd882b9f Fix: unused variable 2022-08-10 13:35:47 +02:00
Mark Spanbroek 9e3a822877 Fix: disregard early symbol lookup for error variable 2022-08-10 13:35:47 +02:00
Mark Spanbroek cfe17ca899 Fix error when using an existing name as error variable 2022-08-10 13:35:47 +02:00
Mark Spanbroek 90ea780ba9 Fix: nested `without` calls in generic code 2022-08-10 13:29:09 +02:00
Mark Spanbroek 4abeef5c36 Fix: `without` statement with error works in nested calls 2022-08-10 13:29:09 +02:00
Mark Spanbroek 22f2c9761a Disable warning about DotLikeOps
Give a clear compiler error when questionable
is used with the -d:nimPreviewDotLikeOps flag.

Reason: the option is likely to be deprecated
or removed. More info:
https://github.com/nim-lang/Nim/pull/19919
2022-08-10 13:28:52 +02:00
Mark Spanbroek 13c7ff7671 Retrieve optional error from Result 2022-08-04 13:52:07 +02:00
Tanguy b0666ba4f1
Fixes for styleCheck:usages (#16)
* Fixes for styleCheck:usages
* Bump nim 1.2 in CI
2022-08-03 15:21:00 +02:00
Ivan Yonchovski 955597a4fd
Add setup/lock files (#14) 2022-07-12 21:34:52 +03:00