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

Optional enum match C error #20663

Closed
HectorPeeters opened this issue Jan 26, 2024 · 2 comments · Fixed by #20673
Closed

Optional enum match C error #20663

HectorPeeters opened this issue Jan 26, 2024 · 2 comments · Fixed by #20673
Assignees

Comments

@HectorPeeters
Copy link
Contributor

HectorPeeters commented Jan 26, 2024

V doctor:

V full version: V 0.4.4 754c83a
OS: linux, "Arch Linux"
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 PRO 4750U with Radeon Graphics

getwd: /home/hector
vexe: /home/hector/Dev/v/v
vexe mtime: 2024-01-26 11:31:42

vroot: OK, value: /home/hector/Dev/v
VMODULES: OK, value: /home/hector/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.0
Git vroot status: weekly.2024.04-11-g754c83a8-dirty
.git/config present: true

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

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

enum Test {
    a
    b
}

fn optional() ?Test {
    return none
}

fn main() {
    match optional() {
        .a { }
        else { }
    }
}

What did you expect to see?

No output

What did you see instead?

==================
/tmp/v_1000/test.01HN3750AMESTN4YW9B51T59G9.tmp.c:12862: error: invalid operand types for binary operation
/tmp/v_1000/test.01HN3750AMESTN4YW9B51T59G9.tmp.c:12862: error: invalid aggregate type for register load
...
==================
(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.

@Delta456
Copy link
Member

I don't think none should be allowed to match as the condition.

@HectorPeeters
Copy link
Contributor Author

I'm not sure I fully understand what you mean here. Intuitively, I would assume the else case would get executed here for none. If matching on an optional value (and thus possibly none) isn't allowed, I guess this case would require some additional logic in the checker.

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.

3 participants