Returning error
in Option type ?
#17423
impopular-guy
started this conversation in
General
Replies: 2 comments 2 replies
-
It's expected for now, since V used to only support a single type that could return either Directly assigning an error to a variable is an error, not a bug. Errors don't have types that can be assigned, they can only be checked in |
Beta Was this translation helpful? Give feedback.
2 replies
-
It should result in a warning about the split, will fix. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I can do the following on an Option type
I can also do this
However, I get
builder error
if I try to directly assign the errorQuestions:
The docs say that Option types may represent
none
and Result may represent error. So I was under the impression that errorcannot be passed when we have Option return type, since Option/Result was separated a while ago. I was able to put error in the option type.
Also the C code tells that
none
is just anIError
. This might be useful when we want to return none as well as error from samefunction, but here we will have to manually check and propagate errors.
a = error('Some error')
a bug? Of course it is because its a builder error. But should such be allowed?Beta Was this translation helpful? Give feedback.
All reactions