Reject non-None kernel return annotations#1475
Conversation
📝 WalkthroughWalkthroughThis PR enforces that Warp kernels cannot declare non- ChangesKernel return annotation validation
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 5-6: The CHANGELOG entry "Raise an error when a kernel is defined
with a non-`None` return annotation." is missing the GitHub issue reference;
update that line to include " (fixes `#1471`)" or similar so the entry closes the
referenced issue (PR closes `#1471`) and follows the repository's changelog
guideline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Enterprise
Run ID: bf3be72d-c55d-406c-b060-71c6eeae7902
📒 Files selected for processing (3)
CHANGELOG.mdwarp/_src/context.pywarp/tests/test_codegen.py
Greptile SummaryThis PR fixes a silent bug where a kernel annotated with a non-
Confidence Score: 5/5Safe to merge — the change adds a new error guard that is narrowly scoped to the kernel build path and does not touch any existing code paths. The fix is small and surgical: one new conditional in build_kernel that fires only when a kernel carries a non-None return annotation but no actual return value. The underlying arg_types dict already strips -> None at parse time, so the guard correctly excludes every valid kernel form. The previously commented-out test case is now activated with proper module isolation, giving direct coverage of the new branch. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build_kernel called] --> B[kernel.adj.build]
B --> C{return_var is not None?}
C -- Yes --> D[raise WarpCodegenTypeError\n'kernels can't have return values']
C -- No --> E{arg_types.get 'return' is not None?}
E -- Yes\n e.g. '-> float' annotation --> F[raise WarpCodegenTypeError\n'kernels can't have return values;\nwrite results to output arguments...']
E -- No\n '-> None' or no annotation --> G[Build proceeds normally]
Reviews (2): Last reviewed commit: "Reject non-None kernel return annotation..." | Re-trigger Greptile |
Signed-off-by: Sebastian Nicolas <snicolas432@gmail.com>
b93d722 to
269396f
Compare
Description
Raises an error when a kernel has a non-
Nonereturn annotation. Closes #1471.Checklist
Test plan
Tested on CPU with:
Bug fix
Previously, the
floatreturn annotation was silently ignored by Warp:This PR makes that code raise:
Summary by CodeRabbit
Bug Fixes
Documentation
Tests