Skip to content

Match in or or block returns unexpected value. #24656

Closed

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.

Activity

  1. added
    BugThis tag is applied to issues which reports bugs.
    on Jun 4, 2025
  2. huly-for-github commented on Jun 4, 2025

    @huly-for-github

    Connected to Huly®: V_0.6-23015

  3. added theissue type on Jun 5, 2025
  4. added
    Status: ConfirmedThis bug has been confirmed to be valid by a contributor.
    Unit: CheckerBugs/feature requests, that are related to the type checker.
    on Jun 5, 2025
  5. self-assigned this
    on Jun 5, 2025
  6. added a commit that references this issue on Jun 5, 2025
    1e71fa3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions