Skip to content

Fix mojo package build under Mojo 1.0.0 - #184

Merged
msaelices merged 2 commits into
mainfrom
fix-mojopkg-build-mojo-1.0
Sep 1, 2026
Merged

msaelices merged 2 commits into
mainfrom
fix-mojopkg-build-mojo-1.0

Conversation

@msaelices

Copy link
Copy Markdown
Owner

Problem

mojo package src/regex fails under Mojo 1.0.0 with 33 errors, so the
conda recipe in modular-community cannot build the .mojopkg. This is
what failed the build on
modular-community#293,
which was closed as a result.

The test suite never caught it: building a test binary does not type-check
every path that packaging does, so pixi run test stayed green the whole
time.

Fixes

  • 31 uses of len() on a String/StringSlice. Mojo 1.0.0 rejects
    these because a single length is ambiguous for UTF-8 text (bytes vs
    codepoints vs graphemes). Every one of them meant the byte count, so they
    become byte_length(). len() on List is deliberately untouched.
  • match_chunk() size parameter could not be inferred at two call
    sites in simd_ops, since it is a parametric trait method. Passed
    explicitly as match_chunk[16](chunk), matching the 16-byte chunk being
    loaded right above.

Prevention

CI ran only pixi run test. Added a step that builds the package, so this
class of breakage fails here instead of in the conda recipe.

Verification

  • mojo package src/regex now succeeds (696 KB .mojopkg)
  • Full suite green: 399 tests, 0 failures

The library compiled and tested fine, but 'mojo package src/regex' failed
with 33 errors, so the conda recipe in modular-community could not build
the .mojopkg. The test suite never caught this because building a test
binary does not type-check every path that packaging does.

Two problems:

- 31 uses of len() on a String or StringSlice. Mojo 1.0.0 rejects these
  because a single length is ambiguous for UTF-8 text. All of them meant
  the byte count, so they become byte_length(). len() on List is
  untouched.
- match_chunk() is a parametric trait method whose size parameter could
  not be inferred at two call sites in simd_ops. Pass it explicitly as
  match_chunk[16](chunk), matching the 16-byte chunk being loaded.

'mojo package src/regex' now succeeds and the full suite still passes
(399 tests, 0 failures).
CI ran only the test suite, which does not type-check every path that
'mojo package' does. That let the package build break while tests stayed
green, and the failure only surfaced in the modular-community conda
recipe build.
@msaelices
msaelices merged commit b8c2045 into main Sep 1, 2026
6 checks passed
@msaelices
msaelices deleted the fix-mojopkg-build-mojo-1.0 branch September 1, 2026 08:16
msaelices added a commit to msaelices/modular-community that referenced this pull request Sep 1, 2026
The previous build failed because 'mojo package src/regex' did not
compile under Mojo 1.0.0: len() on String/StringSlice is rejected there,
and two match_chunk() call sites could not infer their size parameter.
msaelices/mojo-regex#184 fixes both and adds a CI step that builds the
package, so this cannot regress unnoticed again.
alisterburt pushed a commit to modular/modular-community that referenced this pull request Sep 1, 2026
* Bump mojo-regex from 0.10.0 to 0.21.0

* Pin mojo-regex 0.21.0 to a63fd53 (includes final consolidated changelog)

* Use the full 40-char commit SHA in the mojo-regex source rev

rattler-build fetches the rev as a git ref and GitHub only serves
full SHAs, so the short form fails with 'couldn't find remote ref'.

* Pin mojo-regex 0.21.0 to stable Mojo 1.0.0

Mojo 1.0.0 is now released on the stable max channel, so the recipe can
pin mojo_version =1.0.0 (previously a dev nightly that never existed in
the stable channel, which blocked the build). Bumps source rev to the
current mojo-regex main (on stable 1.0.0).

* Point mojo-regex 0.21.0 at the packaging fix for Mojo 1.0.0

The previous build failed because 'mojo package src/regex' did not
compile under Mojo 1.0.0: len() on String/StringSlice is rejected there,
and two match_chunk() call sites could not infer their size parameter.
msaelices/mojo-regex#184 fixes both and adds a CI step that builds the
package, so this cannot regress unnoticed again.

---------

Co-authored-by: Caroline Frasca <42614552+carolinefrasca@users.noreply.github.com>
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.

1 participant