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

C error when trying to append ?Foobar into an array of Foobar #20568

Closed
zeozeozeo opened this issue Jan 17, 2024 · 0 comments · Fixed by #20573
Closed

C error when trying to append ?Foobar into an array of Foobar #20568

zeozeozeo opened this issue Jan 17, 2024 · 0 comments · Fixed by #20573
Assignees

Comments

@zeozeozeo
Copy link
Contributor

zeozeozeo commented Jan 17, 2024

V doctor:

V full version: V 0.4.4 5306469.a79a9cb
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 20 cpus, 64bit, little endian, 

getwd: C:\Users\user\Desktop\Code\leaflang
vexe: C:\Users\user\Desktop\Code\v\v.exe
vexe mtime: 2024-01-17 15:35:51

vroot: OK, value: C:\Users\user\Desktop\Code\v
VMODULES: OK, value: C:\Users\user\.vmodules
VTMP: OK, value: C:\Users\user\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.1
Git vroot status: weekly.2024.03-7-ga79a9cb5
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.


thirdparty/tcc status: thirdparty-windows-amd64 a39eb79b

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

pub enum Foobar {
	foo
	bar
}

fn get_foo_or_none(fail bool) ?Foobar {
	return if fail {none} else {.foo}
}

fn main() {
	mut foobars := []Foobar{}

	// append a ?Foobar into an array of Foobar
	// results in C error
	foobars << get_foo_or_none(false)
	foobars << get_foo_or_none(true)
}

What did you expect to see?

Checker error

What did you see instead?

==================
C:/Users/user/AppData/Local/Temp/v_0/test2.01HMC11JHX95P8NNNGF59M8VNW.tmp.c:6862: warning: implicit declaration of function 'tcc_backtrace'
C:/Users/user/AppData/Local/Temp/v_0/test2.01HMC11JHX95P8NNNGF59M8VNW.tmp.c:12987: error: cannot convert 'struct _option_main__Foobar' to 'enum <anonymous>'
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Relevant generated C code:

VV_LOCAL_SYMBOL void main__main(void) {
	Array_main__Foobar foobars = __new_array_with_default_noscan(0, 0, sizeof(main__Foobar), 0);
	array_push_noscan((array*)&foobars, _MOV((main__Foobar[]){ main__get_foo_or_bar(false) }));
	array_push_noscan((array*)&foobars, _MOV((main__Foobar[]){ main__get_foo_or_bar(true) }));
}

image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants