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 when unwrapping result of enum's from() (to optional value) #20809

Closed
mac-hel opened this issue Feb 12, 2024 · 1 comment · Fixed by #20830
Closed

builder error when unwrapping result of enum's from() (to optional value) #20809

mac-hel opened this issue Feb 12, 2024 · 1 comment · Fixed by #20830
Assignees
Labels
Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@mac-hel
Copy link
Contributor

mac-hel commented Feb 12, 2024

V doctor:

V full version: V 0.4.4 f603035.c9933da
OS: linux, "EndeavourOS Linux"
Processor: 8 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz

getwd: /H/_nobackup/Projects/v_t
vexe: /H/daily/mh/.local/share/v/v
vexe mtime: 2024-02-12 15:34:33

vroot: OK, value: /H/daily/mh/.local/share/v
VMODULES: OK, value: /home/mh/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.1
Git vroot status: weekly.2024.06-56-gc9933da6
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
thirdparty/tcc status: thirdparty-linux-amd64 99683af0

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

enum Operation {
	get_area
	get_sector
}

fn main() {
	operation_name := 'get_area'
        // I want 'operation' to have `?Operation' type
	operation := if o := Operation.from(operation_name) { o } else { ?Operation(none) }
}

this works:

	operation := if o := Operation.from(operation_name) { ?Operation(o) } else { ?Operation(none) }

What did you expect to see?

no builder error, probably compiler error instead

What did you see instead?

/tmp/v_1000/main.01HPEZC36RV5VS0GNSTPAJ2C31.tmp.c:12965: error: cannot convert 'struct _option_main__Operation' 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

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.

@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Feb 12, 2024
@felipensp
Copy link
Member

I see the branches are emitting different types. So it must be a checker error there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants