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 field name error: unexpected keyword none, expecting name #22455

Closed
yuyi98 opened this issue Oct 9, 2024 · 1 comment · Fixed by #22456
Closed

Enum field name error: unexpected keyword none, expecting name #22455

yuyi98 opened this issue Oct 9, 2024 · 1 comment · Fixed by #22456
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@yuyi98
Copy link
Member

yuyi98 commented Oct 9, 2024

Describe the bug

Enum field name error: unexpected keyword none, expecting name

Reproduction Steps

enum TypeKind {
	none
	const
	enum
	struct
	interface
	sumtype
	i32
}

fn main() {}

Expected Behavior

no error.

Current Behavior

yuyi@yuyi-PC:~/test/t1$ v run .
t1.v:2:2: error: unexpected keyword `none`, expecting name
    1 | enum TypeKind {
    2 |     none
      |     ~~~~
    3 |     const
    4 |     enum

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.8 e1480b6

Environment details (OS name and version, etc.)

V full version: V 0.4.8 e1480b6
OS: linux, Deepin 20.9 (VM)
Processor: 6 cpus, 64bit, little endian, AMD Ryzen 7 6800H with Radeon Graphics

getwd: /home/yuyi/test/t1
vexe: /home/yuyi/v/v
vexe mtime: 2024-10-09 02:27:39

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

Git version: git version 2.20.1
Git vroot status: 0.4.8-68-ge1480b61
.git/config present: true

CC version: cc (Uos 8.3.0.3-3+rebuild) 8.3.0
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

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.

@yuyi98 yuyi98 added the Bug This tag is applied to issues which reports bugs. label Oct 9, 2024
@jorgeluismireles
Copy link

I didn't know some "reserved words" would work without the "@", why some do and others don't? This already works:

enum TypeKind {
	@none
	@const
	@if
	enum
	struct
	interface
	sumtype
	i32
	u8
}

struct Types {
	t []TypeKind
}

fn main() {
	t := Types{[.@none, .@const, .@if, .enum, .struct, .u8]}
	assert '${t.t}' == '[none, const, if, enum, struct, u8]'
}

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