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

cgen error when trying to use enum key prematurely #21912

Closed
ratkingsminion opened this issue Jul 23, 2024 · 0 comments · Fixed by #21913
Closed

cgen error when trying to use enum key prematurely #21912

ratkingsminion opened this issue Jul 23, 2024 · 0 comments · Fixed by #21913
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@ratkingsminion
Copy link

ratkingsminion commented Jul 23, 2024

Describe the bug

When trying to find out how to have enum aliases, I found a way by using key2 = int(MyEnum.key1), after testing it a bit further a cgen error appeared when putting key2 before key1.

Reproduction Steps

Code: https://play.vlang.io/p/371a7f8fd6

enum MyEnum {
	a = 1
	b = 2
	c = int(MyEnum.a) // works
}

enum MyEnum2 {
	c = int(MyEnum2.a) // cgen error
	a = 1
	b = 2
}

Expected Behavior

A checker error is expected

Current Behavior

Output:

/tmp/v_60000/code.01J3FEXFSYXDYWVPHW0EHY56K7.tmp.c:847: error: 'main__MyEnum2__a' undeclared
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 .
Exited with error status 1

Possible Solution


Additional Information/Context


V version

V 0.4.6 fd7986c

Environment details (OS name and version, etc.)

V full version: V 0.4.6 fd7986c
OS: linux, Debian GNU/Linux 11 (bullseye) (VM)
Processor: 1 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz

getwd: /home/admin/playground
vexe: /home/admin/v/v
vexe mtime: 2024-07-23 09:25:26

vroot: OK, value: /home/admin/v
VMODULES: OK, value: .vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.30.2
Git vroot status: Error: fatal: detected dubious ownership in repository at '/home/admin/v'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v
.git/config present: true

CC version: cc (Debian 10.2.1-6) 10.2.1 20210110
thirdparty/tcc status: Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc
 Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc

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.

@ratkingsminion ratkingsminion added the Bug This tag is applied to issues which reports bugs. label Jul 23, 2024
@Delta456 Delta456 self-assigned this Jul 23, 2024
@felipensp felipensp changed the title cgenerror when trying to use enum key prematurely cgen error when trying to use enum key prematurely Jul 23, 2024
@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Jul 23, 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. 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.

3 participants