Skip to content

fix(builtin): wrap a uint64 converted to int in generic code - #537

Merged
paralin merged 1 commit into
s4wave:devfrom
cogentcore:fix/generic-int-conversion-wrap
Oct 25, 2026
Merged

paralin merged 1 commit into
s4wave:devfrom
cogentcore:fix/generic-int-conversion-wrap

Conversation

@rcoreilly

Copy link
Copy Markdown
Contributor

A conversion to a type parameter whose type argument is int, T(u), did not wrap a uint64 beyond the int range: for u = 1<<64 - 7 it gave 18446744073709552000 instead of -7, which the non-generic int(u) gives. genericConvert now converts to int with 64 bits, as it does for uint.

This broke code that keeps integers as uint64 bits and converts them back with generic helpers, such as the arithmetic of a bytecode interpreter: -7 % 3 gave 1. generic_typeparam_conversion covers int, int64 and int32.

A conversion to a type parameter whose type argument is int did not wrap
a uint64 beyond the int range, so T(u) for u = 1<<64 - 7 gave
18446744073709552000 instead of -7, as the non-generic int(u) does.

Signed-off-by: Randall C. O'Reilly <oreilly@ucdavis.edu>
@paralin
paralin changed the base branch from master to dev October 25, 2026 18:37
@paralin
paralin merged commit 5bb48e9 into s4wave:dev Oct 25, 2026
7 checks passed
@paralin

paralin commented Oct 25, 2026

Copy link
Copy Markdown
Member

Landed on master as ecd5511, rebased onto the batch #532 to #550, with regenerated fixtures in fca8071.

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