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

match *enum {...} produces C error #23314

Closed
islonely opened this issue Dec 30, 2024 · 0 comments · Fixed by #23316
Closed

match *enum {...} produces C error #23314

islonely opened this issue Dec 30, 2024 · 0 comments · Fixed by #23316
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@islonely
Copy link
Contributor

islonely commented Dec 30, 2024

Describe the bug

C error produced from trying to dereference enum variable as the V error in #23313 advises.

Reproduction Steps

enum Foo {
    zero
    one
}

fn main() {
    shared foo := Foo.one
    rlock foo {
        match *foo {
            .zero { println ('0000') }
            .one { println('1111') }
        }
    }
}

Expected Behavior

Expected code to compile and print 1111.

Current Behavior

================== C compilation error (from cc): ==============
cc: /tmp/v_501/test.01JGB3N270P7H6Y8RGJP798CA5.tmp.c:9331:23: error: incompatible integer to pointer conversion initializing '__shared__main__Foo *' (aka 'struct __shared__main__Foo *') with an expression of type 'int' [-Wint-conversion]
cc:  9331 |         __shared__main__Foo* foo = main__Foo__one;
cc:       |                              ^     ~~~~~~~~~~~~~~
cc: /tmp/v_501/test.01JGB3N270P7H6Y8RGJP798CA5.tmp.c:9336:11: error: invalid operands to binary expression ('__shared__main__Foo' (aka 'struct __shared__main__Foo') and 'int')
cc:  9336 |                 if (_t1 == (main__Foo__zero)) {
cc:       |                     ~~~ ^  ~~~~~~~~~~~~~~~~~
cc: /tmp/v_501/test.01JGB3N270P7H6Y8RGJP798CA5.tmp.c:9339:16: error: invalid operands to binary expression ('__shared__main__Foo' (aka 'struct __shared__main__Foo') and 'int')
cc:  9339 |                 else if (_t1 == (main__Foo__one)) {
cc:       |                          ~~~ ^  ~~~~~~~~~~~~~~~~
cc: 3 errors generated.
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 4225a34

Environment details (OS name and version, etc.)

V full version: V 0.4.9 4225a34
OS: macos, macOS, 15.1.1, 24B91
Processor: 8 cpus, 64bit, little endian, Apple M3

getwd: /Users/adamoates/Documents/shattlebip
vexe: /Users/adamoates/v/v
vexe mtime: 2024-12-29 23:07:43

vroot: OK, value: /Users/adamoates/v
VMODULES: OK, value: /Users/adamoates/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.5 (Apple Git-154)
Git vroot status: weekly.2024.52-23-g4225a346
.git/config present: true

CC version: Apple clang version 16.0.0 (clang-1600.0.26.4)
emcc version: N/A
thirdparty/tcc status: thirdparty-macos-arm64 713692d4

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.

Huly®: V_0.6-21746

@islonely islonely added the Bug This tag is applied to issues which reports bugs. label Dec 30, 2024
@yuyi98 yuyi98 self-assigned this Dec 30, 2024
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

Successfully merging a pull request may close this issue.

2 participants