Skip to content

Sum type with generic doesn't believe its exhaustive and also does at same timeย #27515

Closed

Description

@AdminCrystal

Describe the bug

Sum type with generic doesn't believe its exhaustive and also does at same time. IT does work without the T block and only the else block.

Reproduction Steps

You can reproduce both errors by commenting/uncommenting the else block to switch between the two errors

struct Something {}
type Any[T] = string | int | T

fn something[T](my_var Any[T]) int {
	match my_var {
		string {
			return 1
		}
		int {
			return 0
		}
		// If T is here without else it says monolith.v:6:2: error: match must be exhaustive (add `else {}` at the end)
		T {
			return 3
		}
		// IF T and else are here it says monolith.v:17:3: error: match expression is exhaustive, `else` is unnecessary
		else {
			return 4
		}
	}
	return 1
}

fn main() {
	new_var := 5
	println(something(Something{}))
}

Expected Behavior

Expect it to Complie with the T block, and no else block

Current Behavior

doesnt complie with T block or T block and else block

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.5.1 1704098

Environment details (OS name and version, etc.)

brent@Brents-MacBook-Pro monorepo % v doctor

V full version V 0.5.1 c9c9386.1704098
OS macos, macOS, 26.4.1, 25E253
Processor 12 cpus, 64bit, little endian, Apple M4 Pro
Memory 0.23GB/24GB
V executable /Users/brent/aaaa/v/v
V last modified time 2026-06-21 00:25:28
V home dir OK, value: /Users/brent/aaaa/v
VMODULES OK, value: /Users/brent/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/brent/aaaa/monorepo
Git version git version 2.50.1 (Apple Git-155)
V git status 1704098
.git/config present true
cc version Apple clang version 21.0.0 (clang-2100.0.123.102)
gcc version Apple clang version 21.0.0 (clang-2100.0.123.102)
clang version Apple clang version 21.0.0 (clang-2100.0.123.102)
tcc version tcc version 0.9.28rc 2026-01-10 HEAD@5ec0e6f8 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 f995efa3
emcc version N/A
glibc version N/A
brent@Brents-MacBook-Pro monorepo %

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 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions