Skip to content

Conversation

@tritao
Copy link

@tritao tritao commented May 18, 2025

Summary

This PR adds support for the alignof builtin, allowing users to get the memory alignment (in bytes) of a type or expression.

Highlights

  • New AST node: AlignOf

  • Supports both alignof(expr) and alignof[Type]()

  • Integrated into:

    • Parser, checker, formatter (v fmt)

    • C codegen (via alignof(...) + <stdalign.h>)

    • JS backend (placeholder for now)

  • Updated docs.md and changelog

This improves low-level memory control and brings alignof in line with sizeof.

I know this is missing tests, just want to make sure this is acceptable to add before I put more time into it.

@huly-for-github
Copy link

Connected to Huly®: V_0.6-22877

@felipensp
Copy link
Member

Following this tip from CONTRIBUTING will helps you on next commits (it will do the v fmt on commit changed files to you):

cp cmd/tools/git_pre_commit_hook.vsh .git/hooks/pre-commit
chmod 755 .git/hooks/pre-commit

@tritao
Copy link
Author

tritao commented May 27, 2025

PR has been updated, can someone re-approve to run CI?

@enghitalo
Copy link
Contributor

PR has been updated, can someone re-approve to run CI?

You need to format the code use v fmt w . for this

@tritao
Copy link
Author

tritao commented May 27, 2025

v fmt w .

That wasn't it, I think the files should be already formatted through the setup Git pre-commit hook. I just had an unintended change in fmt.v.

@tritao
Copy link
Author

tritao commented May 29, 2025

There is one pending job, what's the procedure to restart it?

@JalonSolov
Copy link
Contributor

I tried... GitHub simply isn't allocating a runner to run it, so it will sit waiting until GitHub thinks it's OK.

Comment on lines +7431 to +7433
if sym.language == .v && sym.kind in [.placeholder, .any] {
g.error('unknown type `${sym.name}`', node.pos)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a checker error, not in code generation?

@spytheman spytheman closed this Jul 5, 2025
@spytheman spytheman reopened this Jul 5, 2025
@spytheman
Copy link
Member

(I've closed/reopened it to force the CI jobs to run again)

@JalonSolov
Copy link
Contributor

Another close/reopen, due to expired logs.

@JalonSolov JalonSolov closed this Jul 21, 2025
@JalonSolov JalonSolov reopened this Jul 21, 2025
@JalonSolov
Copy link
Contributor

Yet another close/reopen. @tritao do you think you might finish this soon?

@JalonSolov JalonSolov closed this Aug 4, 2025
@JalonSolov JalonSolov reopened this Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants