Get the element by the index or propagate an error to the caller #23452
Labels
Bug
This tag is applied to issues which reports bugs.
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Unit: Parser
Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).
Describe the bug
According to @spytheman , propagating the error of the array out-of-bounds access or getting the element should be possible to be put in parens, so unwrapping the element, in this case
?string
, is possible in the same line. Currently it fails with a compilation error:Reproduction Steps
Code: https://play.vlang.io/p/856327f0f2
Expected Behavior
This should return the element or propagate the error in case of OOB, then unwrap the optional.
Current Behavior
Output:
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.9 d2b30df
Environment details (OS name and version, etc.)
The text was updated successfully, but these errors were encountered: