Fix range type conversions and collection casting in V#475
Conversation
- Introduced generic V helpers `py_list_cast<T>(...)` and `py_set_from_list<T>(...)` to handle conversions from iterables (like `range`). - Updated `BuiltinCallsMixin` to use these helpers instead of invalid direct V casts. - Enhanced type inference for `set(arg)` to correctly identify key types for range and typed array arguments. - Optimized tuple mapping in `v_types.py` to use fixed-size arrays for homogeneous members while retaining struct-based mapping for heterogeneous members. - Implemented deduplication for structs and functions in `VCodeEmitter` to prevent redundant declarations in the generated code. - Fixed regressions in `SumType` and `TupleStruct` emission for unit tests. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Restored tuple mapping in `v_types.py` to use fixed-size arrays for homogeneous members and structs for heterogeneous members to satisfy existing tests. - Reverted `SumType` and `TupleStruct` registration to use `add_struct` instead of `add_helper_struct` to ensure they are emitted in the main module output. - Implemented robust deduplication for structs and functions in `VCodeEmitter`. - Enhanced `set()` built-in handler to correctly infer `map[int]bool` for range arguments by improving type guessing logic. - Cleaned up narrowing logic in `names.py` and removed temporary debug files. - Verified that all 661 transpiler tests pass. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
- Optimized collection conversions from range using `py_list_cast` and `py_set_from_list`. - Improved type inference for `set()` with range arguments. - Restored and optimized tuple mapping in `v_types.py`. - Fixed type registration regressions and implemented deduplication in `VCodeEmitter`. - Cleaned up redundant narrowing casts and updated tests accordingly. - All 664 tests pass. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
- Resolved Mypy static analysis errors in `v_types.py` and `calls_builtin.py`. - Fixed a bug in `set()` transpilation that caused invalid direct V casts. - Optimized collection conversions from range using `py_list_cast` and `py_set_from_list`. - Improved type inference for `set()` with range arguments by enhancing type guessing. - Restored and optimized tuple mapping to support PEP 695 and satisfy existing tests. - Implemented robust deduplication for structs and functions in `VCodeEmitter`. - Cleaned up redundant narrowing casts and verified all 664 tests pass. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
- Resolved Mypy static analysis errors in `v_types.py` and `calls_builtin.py`. - Fixed invalid direct V casts for `set()`, `list()`, and `tuple()` by using generic helpers. - Implemented `py_list_cast` and `py_set_from_list` V helpers in `module.py`. - Improved type inference for `set()` with range and typed array arguments. - Optimized tuple mapping to use fixed-size arrays for homogeneous members while retaining struct-based mapping for heterogeneous members. - Implemented robust deduplication for structs and functions in `VCodeEmitter`. - Cleaned up redundant narrowing casts in `names.py` and `attributes.py`. - Updated tests to align with improved code generation. - Verified all 664 tests pass. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
This PR fixes two specific transpilation issues in
test_range_type.py: invalid casting of an array ([]int) to a map (set) and invalid direct casting of[]intto[]Anyin V.Key changes:
py_list_castandpy_set_from_listinmodule.pyand registered them inmain.pyto handle collection conversions properly in V.calls_builtin.pyto use these helpers. Improved type inference forset()to avoid defaulting tomap[string]boolwhen the input is a range or a typed array.v_types.pyto map homogeneous tuples to fixed-size V arrays (e.g.,[2]int) while maintaining struct-based mapping for heterogeneous ones.VCodeEmitterto deduplicate structs and functions, preventing compilation errors when multiple parts of the transpiler register the same type.test_type_syntax_fixes.pyandtest_union_types.pyrelated to type registration and emission.All 658 transpiler tests passed.
PR created automatically by Jules for task 3409471699143022295 started by @yaskhan