中文版提示词
请扮演资深软件工程师,帮助我修复一段在边界条件下表现异常的代码。我将提供以下信息:

  • 异常输入描述:[描述具体输入,如“传入空数组”“用户名为空字符串”“数值为负数”等]

  • 预期外的结果:[实际输出的错误结果或异常行为]

  • 相关代码:[粘贴代码块,需注明编程语言]

请完成以下任务:

  1. 补全边界条件判断,增加防御性编程(Guard Clauses),确保所有边缘情况得到妥善处理。

  2. 分析我逻辑推理中的盲点(例如遗漏的假设、未考虑的输入组合或隐含依赖)。

  3. 输出修正后的关键代码片段,并解释每处改动的原因。

直接输出分析、修正代码及盲点说明,无需其他内容。


英文版提示词(English Version Prompt)
Please act as a senior software engineer to help me fix a function that fails under edge‑case inputs. I will provide:

  • Edge‑case description: [describe the specific abnormal input, e.g., “empty array,” “empty username string,” “negative number,” etc.]

  • Unexpected result: [the actual wrong output or abnormal behavior]

  • Relevant code: [paste the code block, specifying the programming language]

Please complete the following:

  1. Add missing boundary condition checks and implement defensive programming (Guard Clauses) to handle all edge cases properly.

  2. Identify blind spots in my logical reasoning (e.g., overlooked assumptions, unconsidered input combinations, or hidden dependencies).

  3. Output the corrected key code snippets and explain the rationale for each change.

Provide directly the analysis, revised code, and blind‑spot explanation, without any other content.