Skip to content

[stdlib] Add comptime assert to tuple getitem#6442

Open
martinvuyk wants to merge 1 commit into
modular:mainfrom
martinvuyk:add-assert-tuple-getitem
Open

[stdlib] Add comptime assert to tuple getitem#6442
martinvuyk wants to merge 1 commit into
modular:mainfrom
martinvuyk:add-assert-tuple-getitem

Conversation

@martinvuyk
Copy link
Copy Markdown
Contributor

Add comptime assert to tuple getitem. Caught by @gabrieldemarmiesse in a discord convo

@martinvuyk martinvuyk requested a review from a team as a code owner April 22, 2026 17:45
@github-actions github-actions Bot added mojo-stdlib Tag for issues related to standard library waiting-on-review labels Apr 22, 2026
@martinvuyk martinvuyk force-pushed the add-assert-tuple-getitem branch from 1c2fdc8 to bce7697 Compare April 22, 2026 17:50
Copy link
Copy Markdown
Contributor

@NathanSWard NathanSWard left a comment

Choose a reason for hiding this comment

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

Thank you for catching this!
I'll add this internally but I believe you can use a t-string in the assert message to provide better error diagnostics :)

@NathanSWard
Copy link
Copy Markdown
Contributor

!sync

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label Apr 22, 2026
@martinvuyk martinvuyk force-pushed the add-assert-tuple-getitem branch from bce7697 to 7cbe13f Compare April 22, 2026 18:03
@martinvuyk
Copy link
Copy Markdown
Contributor Author

martinvuyk commented Apr 22, 2026

@NathanSWard could you sync this again? I tried using the Indexer trait but it won't work, so I went back to using Int

I'll add this internally but I believe you can use a t-string in the assert message to provide better error diagnostics :)

Yeah I agree, I think we should revisit all other __getitem_param__ like InlineArray's to give them some clearer messages (I just copied these from there)

@NathanSWard
Copy link
Copy Markdown
Contributor

!sync

@rd4com
Copy link
Copy Markdown
Contributor

rd4com commented Apr 22, 2026

Hi, 👍
Not sure if it could be baked into TypeList struct,
so that all things that uses it get the comp time assert ?
(And not sure if desirable to do it in TypeList too)

(ping to @NathanSWard)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

imported-internally Signals that a given pull request has been imported internally. mojo-stdlib Tag for issues related to standard library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants