Skip to content

C error: Can't parse variable arguments of type option and sumtype #25261

@jorgeluismireles

Description

@jorgeluismireles
V version: V 0.4.11 847c15e, press to see full `v doctor` output
V full version V 0.4.11 e96355a.847c15e
OS linux, Ubuntu 22.04.5 LTS
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz
Memory 0.43GB/3.7GB
V executable /home/jorge/v/v
V last modified time 2025-09-08 18:40:30
V home dir OK, value: /home/jorge/v
VMODULES OK, value: /home/jorge/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/jorge/bugs/250908
Git version git version 2.34.1
V git status weekly.2025.16-741-g847c15e5-dirty
.git/config present true
cc version cc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
gcc version gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
clang version Ubuntu clang version 14.0.0-1ubuntu1.1
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.5 ()
glibc version ldd (Ubuntu GLIBC 2.35-0ubuntu3.10) 2.35

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

struct Empty { 
	
}

type Elem = int | Empty

//fn new_elems(elems []?int) []Elem { workaround
fn new_elems(elems ...?int) []Elem {
	mut out := []Elem{}
	for elem in elems {
		if elem == none { 
			out << Empty{}
		} else { 
			out << elem 
		}
	}
	return out
}

fn main() {
	elems := new_elems(0, none, 2)
	//elems := new_elems([?int(0), none, 2]) workaround
	dump(elems)
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/250908-a.01K4NEFHAEKM7YWJ973WWDVEAK.tmp.c:6382: warning: implicit declaration of function '_option_ok'
cc: /tmp/v_1000/250908-a.01K4NEFHAEKM7YWJ973WWDVEAK.tmp.c:6386: error: cannot convert 'struct array' to 'struct _option_Array__option_int'
=================================================================
(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://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

[250908-a.v:24] elems: [Elem(0), Elem(Empty{}), Elem(2)] (see workaround lines)

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

BugThis tag is applied to issues which reports bugs.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions