You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using match on a sumtype to access a member present in all variants, but where that member is in an embedded struct in one variant, the C code is generated incorrectly and appends the embedded struct name when accessing all variants of the sumtype.
Reproduction Steps
typeSumType= StructA | StructB
structStructA {
member string
}
structStructB {
StructA
}
fnget_member(st SumType) string {
match st {
StructA, StructB {
return st.member
}
}
}
Expected Behavior
Code should complie
Current Behavior
Compiler causes C error:
================== C compilation error (from cc): ==============
cc: /tmp/v_503/bug-sumtype-embedded-member.01J9VN69CT4FPD3NPZB806NEXK.tmp.c:13452:37: error: no member named 'StructA' in 'struct main__StructA'
cc: string _t1 = (*st._main__StructA).StructA.member;
cc: ~~~~~~~~~~~~~~~~~~~~ ^
cc: 1 error generated.
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https:/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered:
edam
added
the
Bug
This tag is applied to issues which reports bugs.
label
Oct 10, 2024
edam
changed the title
Generated get_member() for sumtypes with embedded members causes C errors
Generated match code for sumtypes with embedded members causes C errors
Oct 10, 2024
Describe the bug
When using
match
on a sumtype to access a member present in all variants, but where that member is in an embedded struct in one variant, the C code is generated incorrectly and appends the embedded struct name when accessing all variants of the sumtype.Reproduction Steps
Expected Behavior
Code should complie
Current Behavior
Compiler causes C error:
Possible Solution
None
Additional Information/Context
Generated C code at fault:
V version
V 0.4.8 51b471b
Environment details (OS name and version, etc.)
MacOS
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: