Skip to content

[mojo] Update the codebase to Mojo v0.26.2#185

Merged
forfudan merged 7 commits intoclifrom
mojo
Mar 21, 2026
Merged

[mojo] Update the codebase to Mojo v0.26.2#185
forfudan merged 7 commits intoclifrom
mojo

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Mar 21, 2026

This PR updates the codebase to Mojo v0.26.2. It migrates Decimo's sources, tests, benches, and build tooling to Mojo v0.26.2 while keeping all library APIs and test coverage intact.

Changes:

  • Replace fn with def throughout (v0.26.2 def/fn unification).
  • Migrate imports to std.* namespace (e.g., std.testing, std.collections, std.memory, std.python, std.time).
  • Update string slicing and pointer/SIMD access patterns for v0.26.2 stdlib.
  • Remove redundant AnyType trait conformances from BigDecimal and BigInt10.
  • Adjust CLI build pipeline to vendor/build ArgMojo from a pinned git commit.

Stringable/Representable traits removed from 7 structs (BigInt, BigUInt, BigDecimal, Decimal128, BigInt10, DecimoError, RoundingMode) — replaced by Writable with write_to().

as_string_slice() → StringSlice() in 6 locations across str.mojo, bigdecimal.mojo, decimal128.mojo.

import math → import std.math in constants.mojo.

Explicit Int8() casts in comparison functions across 5 files (13 locations).

Explicit Float64() casts in exponential.mojo (4 locations).

Explicit UInt32(), UInt64(), UInt128() casts across decimal128/arithmetics.mojo, bigint/arithmetics.mojo, bigint/exponential.mojo.

.__str__() on SIMD → str() in 3 files (4 locations).
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Decimo’s Mojo sources, tests, benches, and build tooling to be compatible with Mojo v0.26.2 (including the stdlib module layout and updated trait/constructor patterns), while keeping the library’s APIs and test coverage broadly intact.

Changes:

  • Migrate imports to std.* (e.g., std.testing, std.collections, std.memory, std.python, std.time) across src/tests/benches.
  • Update string slicing, pointer/SIMD access, and copy/move init patterns for Mojo v0.26.2.
  • Adjust CLI build pipeline to vendor/build ArgMojo from a pinned git commit (Pixi task + CI workflow step).

Reviewed changes

Copilot reviewed 125 out of 127 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/toml/test_decimo_toml.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_utility.mojo Update testing imports to std.testing.
tests/decimal128/test_decimal128_sqrt.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_round.mojo Update testing import + byte-slicing syntax for strings.
tests/decimal128/test_decimal128_root_power.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_quantize.mojo Move Python interop imports to std.python; update testing import.
tests/decimal128/test_decimal128_multiply.mojo Move Python interop imports to std.python; update testing import.
tests/decimal128/test_decimal128_modulo.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_logarithm.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_from_string.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_from_int.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_from_float.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_factorial.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_exp_ln.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_divide.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_conversions.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_comparison.mojo Update testing import to std.testing.
tests/decimal128/test_decimal128_arithmetics.mojo Move Python interop imports to std.python; update testing import.
tests/cli/test_tokenizer.mojo Update testing import to std.testing.
tests/cli/test_parser.mojo Update testing import to std.testing.
tests/cli/test_evaluator.mojo Update testing import to std.testing.
tests/cli/test_error_handling.mojo Update testing import to std.testing.
tests/biguint/test_biguint_exponential.mojo Move Python/random/testing to std.*.
tests/biguint/test_biguint_arithmetics.mojo Move Python/random/testing to std.*.
tests/bigint10/test_bigint10_to_int.mojo Update testing import to std.testing.
tests/bigint10/test_bigint10_creation.mojo Move Python interop to std.python; update testing import.
tests/bigint10/test_bigint10_arithmetics.mojo Move Python interop to std.python; update testing import.
tests/bigint/test_bigint_string_format.mojo Update testing import to std.testing.
tests/bigint/test_bigint_sqrt_divmod.mojo Update testing import to std.testing.
tests/bigint/test_bigint_power_shift.mojo Update testing import to std.testing.
tests/bigint/test_bigint_number_theory.mojo Update testing import to std.testing.
tests/bigint/test_bigint_inplace.mojo Update testing import to std.testing.
tests/bigint/test_bigint_inplace_extended.mojo Update testing import to std.testing.
tests/bigint/test_bigint_conversion.mojo Update testing import to std.testing.
tests/bigint/test_bigint_compare_utility.mojo Update testing import to std.testing.
tests/bigint/test_bigint_bitwise.mojo Update testing import to std.testing.
tests/bigint/test_bigint_basic.mojo Update testing import to std.testing.
tests/bigint/test_bigint_arithmetics.mojo Move Python interop to std.python; update testing import.
tests/bigdecimal/test_bigdecimal_trigonometric.mojo Move Python/testing to std.*; update generic arg syntax.
tests/bigdecimal/test_bigdecimal_rounding.mojo Move Python/testing to std.*.
tests/bigdecimal/test_bigdecimal_methods.mojo Update testing import to std.testing.
tests/bigdecimal/test_bigdecimal_exponential.mojo Move Python/testing to std.*.
tests/bigdecimal/test_bigdecimal_exponential_toml.mojo Update testing import to std.testing.
tests/bigdecimal/test_bigdecimal_creation.mojo Move Python interop to std.python; update testing import.
tests/bigdecimal/test_bigdecimal_compare.mojo Move Python/testing to std.*.
tests/bigdecimal/test_bigdecimal_arithmetics.mojo Move Python/testing to std.*.
src/decimo/toml/tokenizer.mojo Update source index tracking + byte-slicing formatting changes.
src/decimo/toml/parser.mojo Move Dict import to std.collections; adopt new copy-init form; update byte slicing.
src/decimo/tests.mojo Move imports to std.*; update copy/move init patterns; adjust write formatting.
src/decimo/str.mojo Move vectorize import to std.algorithm; add ljust/rjust; update StringSlice and SIMD pointer usage.
src/decimo/rounding_mode.mojo Switch from Stringable to Writable printing via write_to.
src/decimo/errors.mojo Move cwd import to std.pathlib; adjust formatting to use decimo.str.ljust; drop Stringable.
src/decimo/decimal128/utility.mojo Move imports to std.*; replace constrained with comptime assert; update shift types.
src/decimo/decimal128/rounding.mojo Move testing import to std.testing; fix scale type to UInt32 in constructors.
src/decimo/decimal128/exponential.mojo Move to std.math/std.time/std.testing; fix scale types to UInt32.
src/decimo/decimal128/decimal128.mojo Move imports to std.*; adjust trait usage + printing; update byte slicing and scale typing.
src/decimo/decimal128/comparison.mojo Move testing import to std.testing; ensure Int8 return types are explicit.
src/decimo/decimal128/arithmetics.mojo Move imports to std.*; normalize scale typing (UInt32) and exponent operand typing.
src/decimo/biguint/exponential.mojo Move imports to std.*; update list pointer/SIMD loads.
src/decimo/biguint/biguint.mojo Move memory import to std.memory; adopt Writable + write_repr_to; update list pointer/SIMD loads and byte slicing.
src/decimo/biguint/arithmetics.mojo Move imports to std.*; update list pointer/SIMD loads/stores.
src/decimo/bigint10/comparison.mojo Ensure Int8 return types are explicit.
src/decimo/bigint10/bigint10.mojo Move imports to std.*; switch to Writable + write_repr_to; update byte slicing.
src/decimo/bigint/exponential.mojo Move math import to std.math; adjust shift operand typing for newer Mojo.
src/decimo/bigint/comparison.mojo Ensure Int8 return types are explicit.
src/decimo/bigint/bitwise.mojo Replace @parameter branching with comptime if + comptime assert.
src/decimo/bigint/bigint.mojo Move memory imports to std.memory; switch to Writable + write_repr_to; update byte slicing.
src/decimo/bigint/arithmetics.mojo Move memory imports to std.memory; normalize shift typing and Int8 returns.
src/decimo/bigdecimal/trigonometric.mojo Move time import to std.time.
src/decimo/bigdecimal/exponential.mojo Move math import to std.math; adjust term-count computations via Float64 conversions.
src/decimo/bigdecimal/constants.mojo Remove unused builtin math import.
src/decimo/bigdecimal/comparison.mojo Ensure Int8 return types are explicit.
src/decimo/bigdecimal/bigdecimal.mojo Move imports to std.*; switch to Writable output; update StringSlice/byte slicing; add write_repr_to.
src/decimo/bigdecimal/arithmetics.mojo Move math import to std.math.
src/cli/main.mojo Update std sys import; migrate ArgMojo API calls to newer builder style; update byte slicing.
src/cli/calculator/tokenizer.mojo Update copy/move init patterns; update StringSlice usage.
src/cli/calculator/display.mojo Move stderr import to std.sys.
python/decimo_module.mojo Move Python bindings/os imports to std.*; adjust BigDecimal string conversion.
pixi.toml Update Mojo version + dependency bounds; add ArgMojo fetch task; adjust CLI build task to package ArgMojo locally.
pixi.lock Update lockfile for new channels/versions; remove argmojo package pin.
benches/decimal128/bench_truncate_divide.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_subtract.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_sqrt.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_round.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_root.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_quantize.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_power.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_multiply.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_modulo.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_log10.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_ln.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_from_string.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_from_int.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_from_float.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_exp.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_divide.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_comparison.mojo Move imports to std.*; adjust division typing for iterations.
benches/decimal128/bench_add.mojo Move imports to std.*; adjust division typing for iterations.
benches/biguint/bench_scale_up_by_power_of_10.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/biguint/bench_biguint_truncate_divide.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/biguint/bench_biguint_subtraction.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/biguint/bench_biguint_sqrt.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/biguint/bench_biguint_multiply.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/biguint/bench_biguint_multiply_complexity.mojo Move imports to std.*; update timing + stdlib collections.
benches/biguint/bench_biguint_from_string.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/biguint/bench_biguint_divide_complexity.mojo Move imports to std.*; update timing + stdlib collections.
benches/biguint/bench_biguint_add.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_truncate_divide.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_to_string.mojo Move imports to std.*; update iteration division typing.
benches/bigint/bench_sqrt.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_shift.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_power.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_multiply.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_from_string.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_floor_divide.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigint/bench_add.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_subtract.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_sqrt.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_round.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_root.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_multiply.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_ln.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_exp.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_divide.mojo Move imports to std.*; update byte slicing and iteration division typing.
benches/bigdecimal/bench_bigdecimal_add.mojo Move imports to std.*; update byte slicing and iteration division typing.
.gitignore Ignore temp/ used by ArgMojo vendoring workflow.
.github/workflows/run_tests.yaml Add CI step to fetch ArgMojo before building CLI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@forfudan forfudan merged commit 52b6076 into cli Mar 21, 2026
9 checks passed
@forfudan forfudan deleted the mojo branch March 21, 2026 13:44
forfudan added a commit that referenced this pull request Mar 23, 2026
This PR updates the codebase to Mojo v0.26.2. It migrates Decimo's
sources, tests, benches, and build tooling to Mojo v0.26.2 while keeping
all library APIs and test coverage intact.

**Changes:**
- Replace `fn` with `def` throughout (v0.26.2 `def`/`fn` unification).
- Migrate imports to `std.*` namespace (e.g., `std.testing`,
`std.collections`, `std.memory`, `std.python`, `std.time`).
- Update string slicing and pointer/SIMD access patterns for v0.26.2
stdlib.
- Remove redundant `AnyType` trait conformances from `BigDecimal` and
`BigInt10`.
- Adjust CLI build pipeline to vendor/build ArgMojo from a pinned git
commit.
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