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
4d631b1ba9
Fix: ensure that options and results are only evaluated once
2022-09-28 11:36:28 +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
Mark Spanbroek
0895a9c065
Fix: without statement with error works in generic code
2022-07-04 09:53:02 +02:00
Nickolay Bukreyev
361948499b
Fix deprecation warning when importing errorban inside the library
...
`errorban` module [has been deprecated][deprecation] since v0.5.0.
The library continued to use it internally, but because of that, it
was triggering its own deprecation warning. This commit splits
`errorban.nim` into two pieces: the warning and actual code.
[deprecation]: https://github.com/status-im/questionable/commit/e66cd2439b
2022-04-04 09:52:01 +02:00
Mark Spanbroek
a748d22350
Fix: ensure that overridden =? operator does not remain in scope
2022-01-12 17:54:24 +01:00
Mark Spanbroek
ef29000f94
Without statement for Results provides access to errors
2022-01-12 17:54:24 +01:00
Mark Spanbroek
cfe4c6fc95
Ensure that =? works with types that do not have a default value
2021-12-04 17:26:08 +01:00
Mark Spanbroek
56a4bca641
Fix typo
2021-08-30 18:13:43 +02:00
Mark Spanbroek
4967084d22
Better errors when using a proc without a return type in a .? chain
2021-08-30 15:58:29 +02:00
Mark Spanbroek
8feb684574
Fix "unused variable" warnings
2021-07-07 09:19:44 +02:00
Mark Spanbroek
4a1783c472
Add documentation comments
2021-06-04 17:34:48 +02:00
Mark Spanbroek
a2ded4f01a
Simplify
2021-06-04 16:38:44 +02:00
Mark Spanbroek
93f5c919fb
Ensure that optional binding works with closures
2021-05-31 16:24:21 +02:00
Mark Spanbroek
d18580bb68
Better error message when adding a void result to a .? chain
2021-05-06 17:28:58 +02:00
Mark Spanbroek
2700038316
Fix use of =? in generic code
2021-05-06 17:12:52 +02:00
Mark Spanbroek
8bf4f27f30
Avoid wrapping option in option when using .?[] operator
2021-05-04 16:17:09 +02:00
Mark Spanbroek
e8ab268758
Ensure that .? chains work in generic code
2021-05-04 15:55:05 +02:00
Mark Spanbroek
0569625f6a
Replace .get with operator !
...
Rationale: when looking for code that might crash it's
easier to spot exclamation marks than invocations of get.
2021-04-19 15:52:07 +02:00
Mark Spanbroek
fa56587bcd
Avoid wrapping option in option and result in result
2021-04-17 19:50:02 +02:00
Mark Spanbroek
ef5f796463
without statement
2021-04-16 12:27:17 +02:00
Mark Spanbroek
827214f7a9
questionable/results also exports chaining and indexing
2021-04-16 12:10:10 +02:00
Mark Spanbroek
144c70580a
Calling success without arguments returns ?!void result
2021-04-15 11:04:26 +02:00
Mark Spanbroek
89850aab50
Makes |?, =? and .option compatible with other types of Result
2021-04-15 10:54:50 +02:00
Mark Spanbroek
fd73ff713f
Adds failure overload that uses result to determine type
2021-04-15 09:47:08 +02:00
Mark Spanbroek
86bfcc1a47
Use failure and success instead of ok and err
...
- Adds `isFailure` and `isSuccess`.
- No longer exports `ok`, `err`, `isErr` and `isOk`.
2021-04-15 09:39:37 +02:00
Mark Spanbroek
e66cd2439b
Remove errorban from public api
...
Reason: pushing pragmas in included files can have
unexpected side-effects.
2021-04-12 16:07:56 +02:00
Mark Spanbroek
3e92c35a85
Rename chaining and indexing operators
...
Chaining operator is now `.?`
Indexing operator is now `.?[]`
Reason: interoperability with the binding `=?` operator.
Chaining and indexing now have lower operator precedence
than binding, ensuring that expressions such as `if a =? b.?c`
work as expected.
2021-04-12 16:07:56 +02:00
Mark Spanbroek
40f5b4f1b8
Allow indexing of tables with ?[]
2021-03-18 17:58:48 +01:00
Mark Spanbroek
91f97c73ef
Evaluate =? expressions only once
2021-03-18 16:59:55 +01:00
Mark Spanbroek
aef59c42eb
Allow optional binding to vars
2021-03-18 09:50:06 +01:00
Mark Spanbroek
74c5089d49
Allow failure() to be called with string argument
2021-03-16 09:45:06 +01:00
Mark Spanbroek
1d5a0222a7
Better type annotations for ->? operator
2021-03-13 11:46:26 +01:00
Mark Spanbroek
43f09e8c86
Rename toOption() -> option()
...
To match the style of std/options, where option() is also used
to convert a ref to an Option.
2021-03-13 11:10:05 +01:00
Mark Spanbroek
b8e52b6acf
Add comments to clarify chaining code
2021-03-13 11:02:27 +01:00
Mark Spanbroek
8683732d99
Chaining operator becomes ?. instead of .?
2021-03-11 17:50:30 +01:00
Mark Spanbroek
53924aeeda
Handle calls and operators following a .? chain
...
Fixes #3
2021-03-11 16:17:26 +01:00
Mark Spanbroek
1ad83adc9d
Convert Result to Option
2021-03-09 09:23:40 +01:00
Mark Spanbroek
59548bcd74
Use operator lifting for the indexing operator
2021-03-08 16:11:01 +01:00
Mark Spanbroek
fe8acac2cd
Fix warning in Nim 1.2.6
2021-03-07 13:07:33 +01:00
Mark Spanbroek
1b47843012
Lift operators so that they can be used on options and results
2021-03-07 13:07:33 +01:00
Mark Spanbroek
81ed9b652c
Initial version of questionable
...
Syntactic sugar for std/options, pkg/result and pkg/stew
2021-03-06 10:38:44 +01:00