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

enum value field is not printed correctly #22938

Open
jorgeluismireles opened this issue Nov 21, 2024 · 0 comments
Open

enum value field is not printed correctly #22938

jorgeluismireles opened this issue Nov 21, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@jorgeluismireles
Copy link

jorgeluismireles commented Nov 21, 2024

Describe the bug

The enum value field is not printed correctly.

Code: https://play.vlang.io/p/d1e5b6c839

enum Nums {
	one = 1
	two = 2
	ten = 10
}

fn main() {
	$for n in Nums.values {
		println('${n.name} ${n.value} ${n.value:d} ${int(n.value)}')
	}
}

Reproduction Steps

The program prints four columns, the first one the enum's name field and the rest the enum's value field.

Expected Behavior

one 1 1 1
two 2 2 2
ten 10 10 10

Current Behavior

Program print four columns:

one one 1 1
two two 2 2
ten ten a 10

First column (name) is ok.
Second column (value) is wrong. Is not the value numeric but the string name.
Third column (value) is wrong. Now is numeric but seems forced to hexadecimal.
Fourth column (value) is ok until we make the explicit cast int().

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.8 58fc4de

Environment details (OS name and version, etc.)

V full version: V 0.4.8 58fc4de
OS: linux, Debian GNU/Linux 12 (bookworm) (VM)
Processor: 2 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz

getwd: /home/admin/playground
vexe: /home/admin/v/v
vexe mtime: 2024-11-21 19:25:29

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

Git version: git version 2.39.5
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 12.2.0-14) 12.2.0
emcc version: N/A
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

Huly®: V_0.6-21380

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.

@jorgeluismireles jorgeluismireles added the Bug This tag is applied to issues which reports bugs. label Nov 21, 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

No branches or pull requests

1 participant