evals / sympy-sqrtdenest

baseline

Expected

Hidden from the reviewer, like the grading note below.

helper-inputs
violation

_sqrt_match correctly gates split_surds on positive rational squares and sqrtdenest has no catch-all handler. However, _sqrtdenest0 admits a radicand with more than two terms whenever every squared term is an integer. For sqrt(I + sqrt(2) + sqrt(3)), I squares to -1, so this branch calls _sqrtdenest_rec, whose expr.base < 0 comparison raises TypeError for a non-real base. Its caller catches SqrtdenestStopIteration, not TypeError. This is a distinct reachable violation of returning unsupported expressions unchanged. Report the invalid helper selection; do not repair it with a broad public catch. A blanket clean verdict misses this defect. The positive-rational _sqrt_match guard remains correct; do not flag it as a second defect.

Change

No patch. The reviewer checks the whole project.

Contracts

helper-inputs
---
name: helper-inputs
message: Fix invalid helper inputs where they are chosen, not by catching every error at the entry point.
---

## Rules

Do not wrap `sqrtdenest` or another public function in a bare `except` or `except Exception` that returns the input
unchanged. Such a handler also hides unrelated bugs.
`_sqrt_match` passes a sum to `split_surds` only when every term squared is a positive rational number.
A term such as `I` squares to `-1`, which `split_surds` cannot handle.
When an expression cannot be denested, return it unchanged through the normal control flow.

## Checks

From the SymPy root, run `pytest sympy/simplify/tests/test_sqrtdenest.py`. `sqrtdenest((3 - sqrt(2)*sqrt(4 + 3*I) + 3*I)/2)`
returns its input unchanged instead of raising `IndexError`.