Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builder error: Incorrect type inference and pattern matching for pointers to sum type elements #23776

Open
russo-2025 opened this issue Feb 20, 2025 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@russo-2025
Copy link

russo-2025 commented Feb 20, 2025

Describe the bug

v -g run file.v

Reproduction Steps

pub type Command = Assign | Call

pub struct Assign {}

pub struct Call {
mut:
	text string
}

fn main() {
	mut command_arr_ptr := [ &Command(Call{}) ]
	mut command_arr_el_ptr := &command_arr_ptr[0] // type is && ?
	
	match mut command_arr_el_ptr {
		Call { //builder error: expected struct or union but not 'struct main__Command *'
			command_arr_el_ptr.text = "foo"
		}
		Assign {

		}
	}
}
pub type Command = Assign | Call

pub struct Assign {}

pub struct Call {
mut:
	text string
}

fn main() {
	mut command_arr_ptr := [ &Command(Call{}) ]
	mut command_arr_el_ptr := command_arr_ptr[0]
	println(typeof(command_arr_el_ptr)) // builder error: expected struct or union but not 'struct main__Command *'
}

Expected Behavior

readable error or ok

Current Behavior

builder error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 6d017f3

Environment details (OS name and version, etc.)

V full version V 0.4.9 a132d97.6d017f3
OS windows,
Processor 16 cpus, 64bit, little endian, Error: cpu - Alias not found.
Memory 45.24GB/63.92GB
V executable M:_dev\vlang\v.exe
V last modified time 2025-02-20 19:25:24
V home dir OK, value: M:_dev\vlang
VMODULES OK, value: C:\Users\russo.vmodules
VTMP OK, value: C:\Users\russo\AppData\Local\Temp\v_0
Current working dir OK, value: C:\Users\russo\Desktop\vbugs
Git version git version 2.47.1.windows.1
V git status weekly.2025.07-69-g6d017f3a
.git/config present true
cc version N/A
gcc version gcc (x86_64-posix-seh, Built by strawberryperl.com project) 8.3.0
clang version N/A
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status N/A
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.

@russo-2025 russo-2025 added the Bug This tag is applied to issues which reports bugs. label Feb 20, 2025
Copy link

Connected to Huly®: V_0.6-22187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant