You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
u64 literals exceeding i64_max are silently clamped to 0x7fffffffffffffff #71
The compiler silently clamps u64 literal values that exceed i64_max (9223372036854775807) to 0x7fffffffffffffff instead of emitting the correct 64-bit value or reporting an error.
Spec reference
§4.1 Integer Types — u64 should support values up to 2^64 - 1 (18446744073709551615).
Reproduction
pub fn main():
var h: u64 = 14695981039346656037 // FNV-1a offset basis
// Expected: 0xcbf29ce484222325
// Actual: 0x7fffffffffffffff (i64_max)
let lo = (h & 255) as i32
print(lo.to_string()) // prints 255, should print 37
Evidence
Disassembly of rt/rt_core.w's fnv_hash function when compiled with the seed:
Stage2 correctly rejects the literal with error: integer literal does not fit expected type, which is a stricter (but also wrong) behavior — it should accept u64 literals up to 2^64 - 1.
Expected behavior
var h: u64 = 14695981039346656037 should store exactly 0xcbf29ce484222325.
Workaround
Use arithmetic expressions: var h: u64 = (0 - 3750763034362895579) as u64 or var h: u64 = ((3421674724 as u64) << 32) | (2216829733 as u64).
Note: the current rt/rt_core.w uses the decimal literal, meaning fnv_hash has always used the wrong offset basis (0x7fffffffffffffff instead of 0xcbf29ce484222325). The hash still distributes keys adequately but does not match standard FNV-1a.
Impact
rt/rt_core.w FNV hash uses wrong offset basis (functional but non-standard)
Stage2 refresh step fails when rt_core.w uses the workaround expression, because the seed-built and stage2-built objects produce different hash values, breaking fixpoint if both are used in the same link
Already fixed in current compiler sources by bc2e537 ("Fix #68: lossless u64/u128 integer literals", April 4, 2026).
What I verified:
current ./out/bin/with-stage1: repro prints 37
current ./out/bin/with-stage2: repro prints 37
installed PATH compiler /Users/eric/.local/bin/with (v0.12.0-663-g6bc26c5ec): repro prints 255
Root cause in the old compiler: integer literals were parsed through a lossy signed path before AST construction. In the old generated seed source, Parser_parse_int_literal calls parse_int directly, so values above i64_max were corrupted before sema/codegen saw them.
Current source no longer does that. HEAD stores exact literal digits/radix in the AST and validates/folds against the exact value, which is why stage1/stage2 both accept and materialize 14695981039346656037u64 correctly.
So this is not a live HEAD bug; it is stale / duplicate of #68, with the remaining reproduction confined to outdated seed binaries. Updating the installed compiler (for example via make install-user after fixpoint) should remove the last visible repro.
Activity
ehartford commentedon Apr 4, 2026
Already fixed in current compiler sources by bc2e537 ("Fix #68: lossless u64/u128 integer literals", April 4, 2026).
What I verified:
Root cause in the old compiler: integer literals were parsed through a lossy signed path before AST construction. In the old generated seed source, Parser_parse_int_literal calls parse_int directly, so values above i64_max were corrupted before sema/codegen saw them.
Current source no longer does that. HEAD stores exact literal digits/radix in the AST and validates/folds against the exact value, which is why stage1/stage2 both accept and materialize 14695981039346656037u64 correctly.
So this is not a live HEAD bug; it is stale / duplicate of #68, with the remaining reproduction confined to outdated seed binaries. Updating the installed compiler (for example via make install-user after fixpoint) should remove the last visible repro.