Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Last updated: 2026-08-08

## typecheck: bare non-negative literals are context-polymorphic (Closes #1923)

- infer_expr pinned every integer literal to I32; in u32-dominant specs every 'let x = 0; x = u32_expr;' raised a false 'cannot assign U32 to I32' -- 27 tri-net specs failed typecheck on exactly this
- Now: bare non-negative literals infer Unknown (context-polymorphic); explicitly negative literals stay I32; promote_types resolves Unknown+Known to the KNOWN operand ('100 - value' with value: u32 is u32)
- tri-net sweep: 27 failing specs -> 2 (both 'assign to immutable array element' singletons, tracked with #1919)
- Unit suite 1537/1537; FROZEN_HASH resealed

## typecheck: promote call-arity mismatch from warning to hard error (Closes #1921)

- The arity check existed but only warned, and nothing reads warnings (tri-net's hook greps 'Typecheck OK'; gen paths skip typecheck) -- two tri-net specs shipped wrong-arity calls for months (tri-net#323)
Expand Down
19 changes: 16 additions & 3 deletions bootstrap/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12794,7 +12794,15 @@ fn infer_expr(node: &Node, symbols: &[SymbolEntry], fns: &[FnEntry]) -> TypeInfo
return TypeInfo::Str;
}
if node.value.parse::<i64>().is_ok() {
return TypeInfo::I32;
// A bare NON-NEGATIVE integer literal is context-polymorphic:
// t27 specs are u32-dominant, and pinning literals to I32 made
// every `let x = 0; ... x = u32_expr;` a false type error
// (27 tri-net specs failed typecheck on exactly this). Only an
// explicitly negative literal commits to a signed type.
if node.value.trim_start().starts_with('-') {
return TypeInfo::I32;
}
return TypeInfo::Unknown;
}
if node.value.parse::<f64>().is_ok() {
return TypeInfo::F64;
Expand Down Expand Up @@ -12851,8 +12859,13 @@ fn promote_types(a: &TypeInfo, b: &TypeInfo) -> TypeInfo {
if a == b {
return a.clone();
}
if *a == TypeInfo::Unknown || *b == TypeInfo::Unknown {
return TypeInfo::Unknown;
// The KNOWN operand determines the type: `100 - value` where value: u32
// is a u32 expression, not an unknown one.
if *a == TypeInfo::Unknown {
return b.clone();
}
if *b == TypeInfo::Unknown {
return a.clone();
}
let a_rank = type_rank(a);
let b_rank = type_rank(b);
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/stage0/FROZEN_HASH
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8770de8b22dfda24d5c4099b2610c4a5a6efd49e43a19e335f08eeb09f788743
37b349425f4d6551c495b3357d229b5a6fb2acf6c55712af4d4ecf5271ec5f53
9 changes: 8 additions & 1 deletion docs/NOW.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# NOW — typecheck: arity mismatch is a hard error (2026-08-08)
# NOW — typecheck: context-polymorphic integer literals (2026-08-08)

Last updated: 2026-08-08

## typecheck: bare non-negative literals are context-polymorphic (Closes #1923)

- infer_expr pinned every integer literal to I32; in u32-dominant specs every 'let x = 0; x = u32_expr;' raised a false 'cannot assign U32 to I32' -- 27 tri-net specs failed typecheck on exactly this
- Now: bare non-negative literals infer Unknown (context-polymorphic); explicitly negative literals stay I32; promote_types resolves Unknown+Known to the KNOWN operand ('100 - value' with value: u32 is u32)
- tri-net sweep: 27 failing specs -> 2 (both 'assign to immutable array element' singletons, tracked with #1919)
- Unit suite 1537/1537; FROZEN_HASH resealed

## typecheck: promote call-arity mismatch from warning to hard error (Closes #1921)

- The arity check existed but only warned, and nothing reads warnings (tri-net's hook greps 'Typecheck OK'; gen paths skip typecheck) -- two tri-net specs shipped wrong-arity calls for months (tri-net#323)
Expand Down
Loading