Skip to content

fix #25508; disallow 'void' as a tuple field type for non generic void#25528

Open
ringabout wants to merge 6 commits intodevelfrom
pr_renege
Open

fix #25508; disallow 'void' as a tuple field type for non generic void#25528
ringabout wants to merge 6 commits intodevelfrom
pr_renege

Conversation

@ringabout
Copy link
Member

@ringabout ringabout commented Feb 18, 2026

fix #25508

@ringabout ringabout changed the title fix #25508; disallow 'void' as a field type fix #25508; disallow 'void' as a field type for non generic void Feb 18, 2026
@ringabout ringabout changed the title fix #25508; disallow 'void' as a field type for non generic void fix #25508; disallow 'void' as a tuple field type for non generic void Feb 18, 2026
@ringabout ringabout marked this pull request as ready for review February 18, 2026 13:02
Copilot AI review requested due to automatic review settings February 18, 2026 13:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes issue #25508 where using void as a tuple field type causes an internal compiler error internal error: getTypeDescAux(tyVoid). The fix adds validation in the semantic analysis phase to reject void types as tuple field types before they reach code generation.

Changes:

  • Added void field type validation in semAnonTuple and semTuple functions
  • Created test case to verify proper error messages for both named and anonymous tuples with void fields

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/errmsgs/t25508.nim Test case verifying void fields in tuples are rejected with clear error messages
compiler/semtypes.nim Added void type checks in tuple semantic analysis to prevent internal errors during code generation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ringabout and others added 4 commits February 18, 2026 21:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@arnetheduck
Copy link
Contributor

why disallow? why not treat it the same as if it appeared in a generic instantiation?

@ringabout
Copy link
Member Author

It's buggy #19335

@Araq
Copy link
Member

Araq commented Feb 25, 2026

Yeah, I don't get it either... The other PR I merged allows void and removes these fields from the tuple.

@ringabout
Copy link
Member Author

ringabout commented Feb 25, 2026

The other PR allows generic voids for tuple fields. It may require codegen changes for a plain void field in a tuple field

@ringabout
Copy link
Member Author

I will see whether I can fix it following #10144

@Araq
Copy link
Member

Araq commented Feb 25, 2026

The problem with void are all coming from the fact that we don't have a value for void and so createThread[void]() must work. We should revisit this idea and then void is simply a type that the backend eliminates: Have a parameter of type void? Ok, don't emit. A variable? A field in an object? All the same, just don't emit it. Zero cost at runtime, all the power for the compile-time. All it takes is to make the value () be of type void and tuple[] be an alias for void, the call then becomes createThread(()) but that's acceptable and even shorter than the explicit [void].

Requires a switch --voidFixed for backwards compat but it's a clean way forward in fixing void-related bugs.

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.

internal error: getTypeDescAux(tyVoid) with either discard default(tuple[b: void]) or discard default((void,))

4 participants