Skip to content

Document def_exc and enums exclusion bit range assumption#1726

Merged
sim642 merged 1 commit intomasterfrom
def_exc-doc-range
Apr 15, 2025
Merged

Document def_exc and enums exclusion bit range assumption#1726
sim642 merged 1 commit intomasterfrom
def_exc-doc-range

Conversation

@sim642
Copy link
Copy Markdown
Member

@sim642 sim642 commented Apr 15, 2025

No description provided.

@sim642 sim642 added the documentation Documentation, comments label Apr 15, 2025
@sim642 sim642 added this to the v2.6.0 milestone Apr 15, 2025
if M.tracing then M.tracel "cast" "Cast %a to range [%a, %a] (%a) = %a (%s in int64)" GobZ.pretty x GobZ.pretty a GobZ.pretty b GobZ.pretty c GobZ.pretty y (if is_int64_big_int y then "fits" else "does not fit");
y

(** @return Bit range corresponds to {e some} {!ikind}, so always includes 0. *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this hold in the case of Unsigned? It seems we try to fit it into a smaller type here: a, upper_bound_less?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ugh, yes, it's not even true here, so I'll remove it.

This does point to bunch of old stuff though. Namely PR #100 which introduced this special behavior to fix some non-associativity problems.
The oddity is how the range doesn't depend on the ikind being used, but the smallest ikind that would fit the value and match the sign of the value. So even with int (with bit range [-31,31]) value 2e9, this otherwise would return [0,32] (for unsigned int). And the special casing turns it into [0,31], which actually is a weaker form of #1723 as well.
My hypothesis is that #1723 should also solve the old non-associativity issue in a less hacky way, but that's beside the point here.

@sim642 sim642 force-pushed the def_exc-doc-range branch from 73e440e to c5c752e Compare April 15, 2025 18:15
@sim642 sim642 merged commit fea1514 into master Apr 15, 2025
20 of 21 checks passed
@sim642 sim642 deleted the def_exc-doc-range branch April 15, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation, comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants