Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Result[] value when it is a tuple #817

Closed
mjfh opened this issue Sep 1, 2021 · 1 comment
Closed

Problems with Result[] value when it is a tuple #817

mjfh opened this issue Sep 1, 2021 · 1 comment

Comments

@mjfh
Copy link
Contributor

mjfh commented Sep 1, 2021

I found some problem/inconsistency when using Result[] objects. The following code:

  var rc = Result[(int,int),void].ok((1,-2))

is sort of unusable. In particular, accessing rc.value[0] would not compile but

  var rc = Result[void,(int,int)].err((1,-2))

works as expected (including access to rc.error[0].)

Did somebody come accross this problem or is it just me?

I could fix the behaviour of the fist example using an object instead of a tuple

  type KVP = object
    key, data: int
  var rc = Result[KVP,void].ok(KVP(key: 1, data: -2))

See attached code file for some more examples.

result_tuple_problem.txt

@mjfh
Copy link
Contributor Author

mjfh commented Oct 2, 2023

As of the current NI version 1.6.12, the following works now

 var rc = Result[(int,int),void].ok((1,-2))
 doAssert rc.value[0] == 1
 doAssert rc.value[1] == -2

@mjfh mjfh closed this as completed Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants