Skip to content

Fix Issue 10549 - allow clamp with int literals on smaller integrals - #11074

Open
niy-ati wants to merge 1 commit into
dlang:stablefrom
niy-ati:fix-10549-clamp-int-literals
Open

Fix Issue 10549 - allow clamp with int literals on smaller integrals#11074
niy-ati wants to merge 1 commit into
dlang:stablefrom
niy-ati:fix-10549-clamp-int-literals

Conversation

@niy-ati

@niy-ati niy-ati commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #10549

Test plan

  • New unittest for ubyte/byte/short/ushort + int literals and return types
  • Existing mixed-sign / uint.max cases still covered by existing unittests
  • clamp(0, long.max, long.max) still rejected at compile time

Integer literals are typed as int, so clamp(ubyte(4), 1, 5) failed the
is(T2 : T1) check after clamp began returning typeof(val). Allow int
bounds when the value type is a smaller integral, cast bounds on return,
and assert that narrowed bounds are representable.
@niy-ati
niy-ati requested a review from PetarKirov as a code owner July 29, 2026 19:15
@0xEAB 0xEAB added Severity:Bug Fix Review:AI Generated Code that is generated by an LLM AI — or suspected to be. labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:AI Generated Code that is generated by an LLM AI — or suspected to be. Severity:Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clamp with smaller-than-int T1 fails to compile with literal parameters

2 participants