Skip to content

preserve pointer type attributes (allowzero, align, volatile, addrspace) - #3321

Open
ilovapples wants to merge 2 commits into
zigtools:masterfrom
ilovapples:fix-pointer-modifier-inlay-hints
Open

ilovapples wants to merge 2 commits into
zigtools:masterfrom
ilovapples:fix-pointer-modifier-inlay-hints

Conversation

@ilovapples

Copy link
Copy Markdown

I hope it's ok for me to pick up this PR; please close this if not. I've been wanting this feature for a while and it doesn't seem like the original author (barrey3406) is planning to work on this anytime soon.

I've rebased and applied techatrix's suggestions from the original code review.
Side note: If it's reasonable to also obtain the address_space from the pointer, I'm not sure how to do it, so any guidance here would be much appreciated.

From the original author's PR comment:

The ptr_type resolver in analysis.zig only read const_token from ptr_info, and Data.createPointer only set is_const on the InternPool.pointer_type flags. So *allowzero u8, *align(4) u8, *volatile u8 and friends all collapsed to *u8 in inlay hints (and anywhere else that runs through stringifyTypeOf).

This reads volatile_token, allowzero_token, and the literal integer in ast.align_node from ptr_info, plumbs them through createPointerType / Data.createPointer into the IP flags and the .pointer Data fallback, and updates rawStringify so the fallback path matches the InternPool printer.

Address-space resolution from arbitrary expressions still defers to .generic; the field is plumbed through but only the literal alignment integer is currently read.

Regression coverage added in tests/lsp_features/inlay_hints.zig.

Fixes #2603."

barry3406 and others added 2 commits November 9, 2026 15:52
The `ptr_type` resolver in analysis.zig only read `const_token` from
`ptr_info`, and `Data.createPointer` only set `is_const` on the
`InternPool.pointer_type` flags. As a result, types like
`*allowzero u8`, `*align(4) u8`, `*volatile u8` were collapsed to
`*u8` in inlay hints (and any other surface that runs through
`stringifyTypeOf`).

Read `volatile_token`, `allowzero_token`, and the integer literal in
`ast.align_node` from `ptr_info`, plumb them through
`createPointerType` / `Data.createPointer` into the IP flags and the
`.pointer` Data fallback, and update `rawStringify` so the fallback
path matches the InternPool printer.

Address-space resolution from arbitrary expressions still defers to
`.generic`; only the literal alignment integer is read for now.

Fixes zigtools#2603.
…Flags, fix type of `slice.ptr`, use different tests
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.

Inline hint of the pointer type is incomplete.

2 participants