Skip to content

Possible regression: Array passed as optional generic argument #25501

@jorgeluismireles

Description

@jorgeluismireles

This code was from issue #24101 . I was looking for unwrap methods and try the code with current V and failed differently.

V version: V 0.4.12 8342968, press to see full `v doctor` output
V full version V 0.4.12 c1d1efb.8342968
OS linux, Ubuntu 22.04.5 LTS
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz
Memory 0.42GB/3.7GB
V executable /home/jorge/v/v
V last modified time 2025-10-14 15:12:48
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
Git version git version 2.34.1
V git status weekly.2025.16-904-g83429685-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.11) 2.35

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

fn main() {
	mut arr := []int{}
	mut bbb := unwrap(mut arr)
	bbb << 1
	dump(bbb)
}
fn unwrap[T](mut t ?T) T {
	return t or { panic('unexpected `none`') }
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/251014.01K7HMJ3ED4SZN5CB44QJ467CZ.tmp.c:5228: warning: assignment from incompatible pointer type
cc: /home/jorge/v/thirdparty/tcc/lib/libgc.a: error: 'GC_noop1_ptr' defined twice
cc: tcc: error: undefined symbol 'builtin___option_ok'
...
cc: tcc: error: undefined symbol 'builtin___option_ok'
(note: the original output was 4 lines long; it was truncated to its first 3 lines + the last line)
=================================================================
(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?

compiled program

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.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: markusedBugs/feature requests, that are related to the -skip-unused.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions