Closed pd-giz-dave closed 7 months ago
@pd-giz-dave because you assign at the labels var in your function a struct that does not exist ( struct assignation declaration in your example ) and you trying to return it. Moreover, return type of your function is not a struct.
It's not a bug.
The type alias documentation is this: "Type aliases To define a new type NewType as an alias for ExistingType, do type NewType = ExistingType. This is a special case of a sum type declaration." So is "[][]int" not a type? I'm a newbie to V so I niaively interpreted a type alias like a C #define, ie. anywhere where ExistingType is valid so would NewType be. My understanding is clearly wrong, but a fuller explanation in the docs would help.
No, you are correct, you have just run into a bug.
If we change array to map on Labels
, we'll get:
bug.v:7:16: error: direct map alias init is not possible, use
Labels(map[int]string{})instead
So, if we want to support array init via this struct way, probably we should support map too for consistency.
Describe the bug
This does not compile:
Reproduction Steps
Try to compile the above code.
Expected Behavior
I would expect it to compile with no error.
Current Behavior
Get compiler error:
Possible Solution
Either fix or update documentation to say its not allowed.
Additional Information/Context
No response
V version
V 0.4.4 ac2dcc2
Environment details (OS name and version, etc.)
EndeavourOS