Switch starter.mojo kernels and solve from fn to def#240
Merged
kunal-mansukhani merged 1 commit intomainfrom Apr 5, 2026
Merged
Switch starter.mojo kernels and solve from fn to def#240kunal-mansukhani merged 1 commit intomainfrom
kunal-mansukhani merged 1 commit intomainfrom
Conversation
Mojo 26.2 deprecates the `fn` keyword. Per the RFC "Remove fn from Mojo" (accepted 23 Feb 2026), `def` is becoming Mojo's single function declaration keyword: - `def foo(...)` — non-raising (matches old `fn`) - `def foo(...) raises` — raising form (replaces old `fn ... raises` and the old implicitly-raising `def`) `fn` will be removed before 1.0. Starters emit a deprecation warning on every compile today; refactor to the new form now so users don't learn the dead keyword. Kernels become `def` without `raises` (they don't raise). `solve` becomes `def ... raises` since it calls DeviceContext, compile_function, enqueue_function, and synchronize — all of which raise. Verified against Mojo 26.2 on a Tesla T4: the transformed vector_add starter compiles cleanly and produces a valid shared library. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
251dc02 to
aeeeb12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mojo 26.2 deprecates the `fn` keyword per the RFC "Remove fn from Mojo, def no longer implies raises" (accepted 23 Feb 2026). Going forward:
`fn` will be removed before 1.0. Every starter currently emits a deprecation warning on compile. This sweeps all 79 `starter.mojo` files to the new form now so learners don't see the dead keyword.
Mapping
Kernels drop to plain `def` — they don't raise. `solve` keeps the `raises` because it calls `DeviceContext`, `compile_function`, `enqueue_function`, and `synchronize`, all of which raise.
Test plan
🤖 Generated with Claude Code