Skip to content

C error in or {} block #26002

Description

@gechandesu
V version: V 0.4.12 3cf0c92, press to see full `v doctor` output
V full version V 0.4.12 ebf629d.3cf0c92
OS linux, Linux version 6.17.9-arch1-1 (linux@archlinux) (gcc (GCC) 15.2.1 20251112, GNU ld (GNU Binutils) 2.45.1) #1 SMP PREEMPT_DYNAMIC Mon, 24 Nov 2025 15:21:09 +0000
Processor 16 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i5-1240P
Memory 5GB/15.34GB
V executable /home/ge/.vlang/v
V last modified time 2025-12-17 15:29:14
V home dir OK, value: /home/ge/.vlang
VMODULES OK, value: /home/ge/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /tmp
Git version git version 2.52.0
V git status weekly.2025.50-65-g3cf0c929
.git/config present true
cc version cc (GCC) 15.2.1 20251112
gcc version gcc (GCC) 15.2.1 20251112
clang version clang version 21.1.6
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (GNU libc) 2.42

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

fn foo(a int) !int {
	if a < 0 {
		return error('foo')
	}
	return a
}

fn bar(a int) !int {
	return foo(a) or {
		if a < 0 {
			-1
		} else {
			return error('bar')
		}
	}
}

fn main() {
	assert bar(0)! == 0
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/or_block_c_error.01KCPEWAJFMZRHA0T0TE3VTY2F.tmp.c:4928: error: cannot convert 'struct _result_int' to 'int'
=================================================================
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?

Maybe a V checker error? IDK. Definitely not a C error.

Additional info

return -1 instead of just -1 resolves the issue.

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

Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: CheckerBugs/feature requests, that are related to the type checker.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions