From f578a0d94f54b62eb465242503bd5a4051dd48a9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 18 Mar 2026 13:51:05 +0000 Subject: [PATCH] docs: create translation issues report for 5 test files Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com> --- translation_issues.md | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 translation_issues.md diff --git a/translation_issues.md b/translation_issues.md new file mode 100644 index 00000000..bc4306d1 --- /dev/null +++ b/translation_issues.md @@ -0,0 +1,61 @@ +# Translation Issues Found + +This report documents issues found when transpiling five test files from to V using the CLI. + +## Files Transpiled +1. `test_match_pattern.py` +2. `test_walrus.py` +3. `test_fstrings_312.py` +4. `test_any_all.py` +5. `test_aug_assign.py` + +--- + +## 1. test_match_pattern.py + +### Issues Found: +- **Missing Imports**: The generated V code uses `py2v_transpiler.core.parser.PyASTParser()` and `ast.py_Module`, but neither `py2v_transpiler` nor `ast` modules are imported in the V file. +- **Dynamic Type Check (`is`)**: The use of `if !tree is ast.py_Module` assumes that `ast.py_Module` is a valid V type at that point, which it isn't without proper module mapping or definition. +- **Exception Handling**: Uses `vexc.raise`, which is part of the non-idiomatic `div72.vexc` approach. + +--- + +## 2. test_walrus.py + +### Issues Found: +- **String Interpolation in println**: The transpiler correctly uses `println('${x}')`. No major issues found here, though complex walrus expressions in `while` loops are transformed into a `for { ... }` block with a break, which is idiomatic for V but might be complex to read. + +--- + +## 3. test_fstrings_312.py + +### Issues Found: +- **C.try() and vexc**: Uses `if C.try() { ... } else { ... }` for Python's `try/except` blocks. This requires `div72.vexc` and C interop, which is not idiomatic V. +- **Nested F-Strings**: Transpiles `f"Val: {f'nested {x}'}"` to `'Val: ${\"nested ${x}\"}'`. While V supports some interpolation, double nested interpolations with quotes might be tricky for the V compiler depending on the version. +- **Missing Helper Reference**: In `test_fstring_312_debug`, it asserts `println('x=${py_repr(x)}')`, but `py_repr` is not defined in the generated `*_helpers.v` file (based on the `cat` output, it was missing in the emitted helpers). + +--- + +## 4. test_any_all.py + +### Issues Found: +- **Missing Imports**: Similar to `test_match_pattern.py`, it uses `py2v_transpiler.core.parser.PyASTParser()` and `ast.py_Module` without imports. +- **Native Method Assumption**: Transpiles `any(a)` to `a.any(it)`. This assumes that the V array type has an `.any()` method or that a suitable extension method is provided. V's standard library arrays do NOT have `.any()` or `.all()` by default (they use `.any()` in some experimental/iter modules, but not on standard arrays without helper injection). However, no such helper was found in the `*_helpers.v` file. + +--- + +## 5. test_aug_assign.py + +### Issues Found: +- **Math Module**: Correctly identifies the need for `import math` when using `**=`, but relies on the transpiler to inject this into the V file. +- **Cast to int**: For `x **= 3` where `x` is an int, it generates `x = int(math.pow(x, 3))`. This is correct for V since `math.pow` returns `f64`. +- **Complex Subscripts**: Uses `py_aug_tmp_1 := f()` to avoid side effects when evaluating the target of an augmented assignment. This is a good implementation of Python's behavior. + +--- + +## General Observations (Across all files) + +1. **Helper Completeness**: Many "built-in" Python functions (like `any`, `all`, `py_repr`) are transpiled to V method calls or helper calls that are not actually present in the generated `*_helpers.v` file. +2. **Module Mapping**: The transpiler often leaves Python-specific module paths (like `py2v_transpiler.core.parser`) in the V code, which will not compile in V. +3. **V-Idiomatic Error Handling**: The use of `C.try()` and `vexc` remains a significant hurdle for idiomatic V code generation. +4. **LLM Markers**: The transpiler correctly inserts `//##LLM@@` warnings for known limitations like `try/except` or complex formatting.