Summary
Move the monomorphic math.sum(list[int64]) returns int64 helper from its hardcoded checker signature and Rust interpreter body into the exported compiler-shipped .jett math module, while preserving consuming ownership and deterministic overflow behavior.
This is a narrow follow-up to #28 / PR #30. It covers only an aggregate helper whose existing public type is directly expressible in Jett; it does not broaden the closed compiler-owned numeric overload boundary.
Source documentation
Current state
math.sum has a hardcoded list[int64] -> int64 signature in jett_typecheck and an interpreter dispatch arm that loops over a runtime list. The existing run-pass fixture covers a representative non-empty sum. PR #47 separately changes unchecked host accumulation into a deterministic overflow error and adds an int64.MAX + 1 runtime-failure regression.
Unlike math.abs, math.min, and math.max, math.sum does not require the compiler-owned int64/float64 overload table. Its body can be expressed with an int64 accumulator, ordinary list iteration, and checked source-level addition. The current helper consumes its list argument rather than borrowing it; extraction must preserve that ownership behavior.
Scope
Includes:
- add exported
math.sum(values: list[int64]) returns int64 source under the compiler-shipped math stdlib module;
- remove only the dedicated hardcoded typechecker signature and Rust interpreter dispatch arm for
math.sum;
- preserve an empty-list result of
0, normal and negative accumulation, argument/return diagnostics, consuming ownership, and deterministic overflow reporting;
- add focused loader/query coverage proving the helper resolves from compiler-shipped source;
- align
docs/design.md, docs/architecture.md, and docs/progress.md with the resulting source/kernel boundary.
Explicitly excludes:
math.abs, math.min, and math.max, which remain compiler-owned exact numeric overloads;
math.average and math.median, whose generic numeric and empty-input contracts are not source-expressible without a separate decision;
math.clamp, whose invalid-bound and NaN behavior remains host-dependent;
math.gcd, math.lcm, and math.factorial, whose int64.MIN, overflow, negative-input, or saturation contracts need separate treatment;
- changing list ownership, generic numeric constraints, implicit coercion, module/import policy, or trusted stdlib origin;
- HIR, MIR, native code generation, or runtime ABI work.
Acceptance criteria
Dependencies / open questions
Land or rebase on #47 so the intended overflow regression is present before removing the Rust dispatch arm. Coordinate the physical stdlib/math.jett module with #28 / PR #30 rather than creating a second competing math namespace file. The implementation should decide whether ordinary source arithmetic's integer overflow wording is sufficient or whether call-context diagnostics must retain the existing math.sum: prefix.
This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.
Summary
Move the monomorphic
math.sum(list[int64]) returns int64helper from its hardcoded checker signature and Rust interpreter body into the exported compiler-shipped.jettmath module, while preserving consuming ownership and deterministic overflow behavior.This is a narrow follow-up to #28 / PR #30. It covers only an aggregate helper whose existing public type is directly expressible in Jett; it does not broaden the closed compiler-owned numeric overload boundary.
Source documentation
docs/progress.md— Phase D,Core stdlib (.jett files)docs/progress.md— Phase K,mathdocs/open_design/math_numeric_overload_boundary.mdCurrent state
math.sumhas a hardcodedlist[int64] -> int64signature injett_typecheckand an interpreter dispatch arm that loops over a runtime list. The existing run-pass fixture covers a representative non-empty sum. PR #47 separately changes unchecked host accumulation into a deterministic overflow error and adds anint64.MAX + 1runtime-failure regression.Unlike
math.abs,math.min, andmath.max,math.sumdoes not require the compiler-ownedint64/float64overload table. Its body can be expressed with anint64accumulator, ordinary list iteration, and checked source-level addition. The current helper consumes its list argument rather than borrowing it; extraction must preserve that ownership behavior.Scope
Includes:
math.sum(values: list[int64]) returns int64source under the compiler-shipped math stdlib module;math.sum;0, normal and negative accumulation, argument/return diagnostics, consuming ownership, and deterministic overflow reporting;docs/design.md,docs/architecture.md, anddocs/progress.mdwith the resulting source/kernel boundary.Explicitly excludes:
math.abs,math.min, andmath.max, which remain compiler-owned exact numeric overloads;math.averageandmath.median, whose generic numeric and empty-input contracts are not source-expressible without a separate decision;math.clamp, whose invalid-bound and NaN behavior remains host-dependent;math.gcd,math.lcm, andmath.factorial, whoseint64.MIN, overflow, negative-input, or saturation contracts need separate treatment;Acceptance criteria
math.sum(values: list[int64]) returns int64with the existing public call spelling.math.sumhardcoded checker signature and Rust execution body are removed.math.sumretains the current consuming ownership behavior, including a compile-fail regression for reuse after the call.int64.MAX + 1case remains a deterministic runtime error after fix: report math.sum overflow #47; any source-boundary diagnostic wording is decided explicitly and pinned rather than changed accidentally.cargo fmt --check,cargo build, andcargo test -qpass.Dependencies / open questions
Land or rebase on #47 so the intended overflow regression is present before removing the Rust dispatch arm. Coordinate the physical
stdlib/math.jettmodule with #28 / PR #30 rather than creating a second competing math namespace file. The implementation should decide whether ordinary source arithmetic'sinteger overflowwording is sufficient or whether call-context diagnostics must retain the existingmath.sum:prefix.This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.