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

Printing custom attributes #23252

Closed
oversoul opened this issue Dec 23, 2024 · 0 comments · Fixed by #23254
Closed

Printing custom attributes #23252

oversoul opened this issue Dec 23, 2024 · 0 comments · Fixed by #23254
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: markused Bugs/feature requests, that are related to the -skip-unused.

Comments

@oversoul
Copy link

oversoul commented Dec 23, 2024

Describe the bug

Printing custom attributes

Reproduction Steps

module main

struct Post {
    title string @[alias]
}

fn main() {
    $for field in Post.fields {
        println(field.attrs)
    }
}

Expected Behavior

I think it should just list the attributes

Current Behavior

cc: /tmp/v_1000/main.01JFTQSYZDSMYV3YXSS51993ZG.tmp.c:5578: warning: implicit declaration of function 'new_array_from_c_array'
cc: /tmp/v_1000/main.01JFTQSYZDSMYV3YXSS51993ZG.tmp.c:5578: error: cannot convert 'int' to 'struct array'

Possible Solution

after some testing, if i just update the code like so:

module main

struct Post {
    title string @[alias]
}

enum Color {
	red   @[RED]  // first attribute
	blue  @[BLUE] // second attribute
}


fn main() {
    $for field in Post.fields {
        println(field.attrs)
    }
    $for e in Color.values {
	println(e.name)
	println(e.attrs)
    }
}

it works just fine.

Additional Information/Context

No response

V version

V 0.4.9 3953445

Environment details (OS name and version, etc.)

V full version: V 0.4.9 3953445
OS: linux, Debian GNU/Linux 12 (bookworm)

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-21686

@oversoul oversoul added the Bug This tag is applied to issues which reports bugs. label Dec 23, 2024
@JalonSolov JalonSolov added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Dec 23, 2024
@felipensp felipensp added the Unit: markused Bugs/feature requests, that are related to the -skip-unused. label Dec 24, 2024
@felipensp felipensp self-assigned this Dec 24, 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. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: markused Bugs/feature requests, that are related to the -skip-unused.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants