Skip to content

CGEN Error: Embedded ? in struct #26622

Description

@mike-ward
V version: V 0.5.0 de7fba1, press to see full `v doctor` output
V full version V 0.5.0 213fad4.de7fba1
OS macos, macOS, 26.2, 25C56
Processor 8 cpus, 64bit, little endian, Apple M2
Memory 0.17GB/8GB
V executable /Users/mike/Documents/github/v/v
V last modified time 2026-02-16 01:00:13
V home dir OK, value: /Users/mike/Documents/github/v
VMODULES OK, value: /Users/mike/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/mike/v-bugs
env VFLAGS "-message-limit 5"
env LDFLAGS "-L/opt/homebrew/opt/ruby/lib"
Git version git version 2.53.0
V git status de7fba1-dirty
.git/config present true
cc version Apple clang version 17.0.0 (clang-1700.6.3.2)
gcc version Apple clang version 17.0.0 (clang-1700.6.3.2)
clang version Apple clang version 17.0.0 (clang-1700.6.3.2)
tcc version tcc version 0.9.28rc 2026-01-10 HEAD@5ec0e6f8 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 f995efa3
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg optional_enum_minify_bug.v && optional_enum_minify_bug

module main

pub enum MyMode as u8 {
	inherit
	a
	b
}

@[minify]
struct Cfg {
	mode ?MyMode
	ok   bool
}

fn main() {
	cfg := Cfg{}
	println(cfg.ok)
}

What did you see?

================== C compilation error (from cc): ==============
cc: /tmp/v_501/optional_enum_minify_bug.01KHPGG5Q0TPDKGAXK335Q45VP.tmp.c:568:23: error: bit-field 'mode' has non-integral type '_option_main__MyMode' (aka 'struct _option_main__MyMode')
cc:   568 |         _option_main__MyMode mode : 2;
cc:       |                              ^      ~
cc: 1 error generated.
================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
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://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

C compiler error

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions