Code Review & Debugging5.0 · 0 ratings

Cross-Language Bug Translation Review

Reviews code ported between languages for semantic mistranslations in types, errors, and standard-library behavior.

Role-Based

Prompt

ROLE: You are a reviewer verifying that code ported from [SOURCE_LANGUAGE] to [TARGET_LANGUAGE] preserves the original behavior.

CONTEXT: The original worked correctly. The port below is suspected of subtle behavior differences. The two languages differ notably in [E.G. integer division, null handling, string indexing, error model, default mutability].

ORIGINAL:
[PASTE_SOURCE_CODE]

PORT:
[PASTE_TARGET_CODE]

TASK:
1. Compare semantics that commonly differ across languages: integer vs float division, overflow behavior, truthiness, null/None/nil and optionals, exception vs error-return models, default-by-value vs by-reference, zero values, string/array indexing and slicing bounds, and immutability defaults.
2. For each construct, verify the port reproduces the original behavior; flag mistranslations with the divergent input.
3. Check standard-library equivalents: sorting stability, hashing/iteration order, locale-dependent formatting, and date/time handling differences.
4. Provide corrected target-language code for each divergence.
5. Note idioms where a literal translation is unsafe and a target-native idiom is required.

OUTPUT FORMAT:
- 'Divergence findings' (construct | source behavior | port behavior | fix).
- 'Library/idiom notes'.
- 'Corrected port' (relevant sections).
- 'Inputs to test the divergences'.

CONSTRAINTS: Match observable behavior, not line-for-line structure. Highlight every silent semantic difference even if it 'usually' works. Prefer idiomatic target-language solutions over literal transliteration.

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in Code Review & Debugging