Skip to content

Match in or or block returns unexpected value. #24656

Description

@mike-ward

Describe the bug

Match in or or block returns unexpected value.

Reproduction Steps

struct Foo {
	option ?int = none
}

fn main() {
	test := true
	foo := Foo{}
	result := foo.option or {
		match test {
			true { 1 }
			else { 2 }
		}
	}

	assert result == 1
}

Expected Behavior

assert should not fail

Current Behavior

./main.v:15: FAIL: fn main.main: assert result == 1
  left value: result = 0
  right value: 1
V panic: Assertion failed...

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.10 262a72e

Environment details (OS name and version, etc.)

V full version V 0.4.10 da3112e.262a72e
OS macos, macOS, 15.5, 24F74
Processor 8 cpus, 64bit, little endian, Apple M2
Memory 0.16GB/8GB
V executable /Users/mike/Documents/github/v/v
V last modified time 2025-06-03 18:43:40
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/Documents/github/bug
env VFLAGS "-path /Users/mike/Documents/github
Git version git version 2.49.0
V git status weekly.2025.17-211-g262a72ea
.git/config present true
cc version Apple clang version 17.0.0 (clang-1700.0.13.5)
gcc version Apple clang version 17.0.0 (clang-1700.0.13.5)
clang version Apple clang version 17.0.0 (clang-1700.0.13.5)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 c8df4e27
emcc version N/A
glibc version N/A

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: 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