Skip to content

compiler: add range param attr to slice/string len/cap#5162

Draft
niaow wants to merge 1 commit intotinygo-org:devfrom
niaow:range-attr
Draft

compiler: add range param attr to slice/string len/cap#5162
niaow wants to merge 1 commit intotinygo-org:devfrom
niaow:range-attr

Conversation

@niaow
Copy link
Copy Markdown
Member

@niaow niaow commented Jan 7, 2026

This attaches the maximum valid len/cap to string/slice fuction parameters. The compiler can use this to:

  1. Prove that index math will not overflow
  2. Prove that signed and unsigned comparisons are equivalent

This depends on tinygo-org/go-llvm#72

Closes #5147

This attaches the maximum valid len/cap to string/slice fuction parameters.
The compiler can use this to:
1. Prove that index math will not overflow
2. Prove that signed and unsigned comparisons are equivalent
@niaow
Copy link
Copy Markdown
Member Author

niaow commented Jan 8, 2026

This is failing because the bindings changed the default LLVM version to 21 which we do not support

Copy link
Copy Markdown
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

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

Nice optimization, thanks!
If you rebase tinygo-org/go-llvm#72 on the main branch the build failures should be fixed (see tinygo-org/go-llvm#74).

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.

2 participants