Commit cf17604
fix(codegen): Resolve integer-to-float coercion in class method comparisons (Refs DEPYLER-0720)
Root Cause: When comparing float class fields (self.balance) with integer
literals (0), the transpiler generated `self.balance > 0` instead of
`self.balance > 0f64`, causing E0308 type mismatch.
Solution:
- Add class_field_types HashMap to ExprConverter to track field types
- Update expr_returns_float_direct() to check self.field patterns
- Add int-to-float coercion for comparison operators (Gt, Lt, Eq, etc.)
- Create convert_method_body_block() for class-field-aware method conversion
- Pass class field types from convert_method_to_impl_item
Before: return self.balance > 0;
After: return self.balance > 0f64;
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent ea580f1 commit cf17604
File tree
3 files changed
+898
-169
lines changed- crates/depyler-core/src
- examples
3 files changed
+898
-169
lines changed
0 commit comments