Repository: sympy/sympy

Issue:
Checksol shouldn't try to call `bool` on a potentially unevaluated expression
```
>>> from sympy import *
>>> x = Symbol('x')
>>> e = -erf(x**(S(1)/3))**pi + I
>>> solve(e, x)
Traceback (most recent call last):
  File "test.py", line 28, in <module>
    print(solve(e, x))
  File "/home/eward/se/sympy/solvers/solvers.py", line 1194, in solve
    solution = _solve(f[0], *symbols, **flags)
  File "/home/eward/se/sympy/solvers/solvers.py", line 1785, in _solve
    result = [r for r in result if
  File "/home/eward/se/sympy/solvers/solvers.py", line 1786, in <listcomp>
    checksol(f_num, {symbol: r}, **flags) is not False]
  File "/home/eward/se/sympy/solvers/solvers.py", line 360, in checksol
    return bool(abs(val.n(18).n(12, chop=True)) < 1e-9)
  File "/home/eward/se/sympy/core/relational.py", line 376, in __nonzero__
    raise TypeError("cannot determine truth value of Relational")
TypeError: cannot determine truth value of Relational
```

There is no guarantee that calling `.n` on an object will actually evaluate it.

This line should use `is True` or something similar:

https://github.com/sympy/sympy/blob/9d6911cc439a80dcf06c3fa645b7de2ce2d75155/sympy/solvers/solvers.py#L360


Discussion:

Patch:
diff --git a/sympy/solvers/solvers.py b/sympy/solvers/solvers.py
index b9db60f9e6..5865c6a071 100644
--- a/sympy/solvers/solvers.py
+++ b/sympy/solvers/solvers.py
@@ -357,7 +357,7 @@ def checksol(f, symbol, sol=None, **flags):
         if numerical and val.is_number:
             if val in (S.true, S.false):
                 return bool(val)
-            return bool(abs(val.n(18).n(12, chop=True)) < 1e-9)
+            return (abs(val.n(18).n(12, chop=True)) < 1e-9) is S.true
         was = val
 
     if flags.get('warn', False):


Test patch:
diff --git a/sympy/solvers/tests/test_solvers.py b/sympy/solvers/tests/test_solvers.py
index 46fe14accb..6a90290bc6 100644
--- a/sympy/solvers/tests/test_solvers.py
+++ b/sympy/solvers/tests/test_solvers.py
@@ -2125,6 +2125,10 @@ def test_issue_17452():
     assert solve(x**(x/11) + pi/11, x) == [exp(LambertW(-11*log(11) + 11*log(pi) + 11*I*pi))]
 
 
+def test_issue_17799():
+    assert solve(-erf(x**(S(1)/3))**pi + I, x) == []
+
+
 def test_issue_17650():
     x = Symbol('x', real=True)
     assert solve(abs((abs(x**2 - 1) - x)) - x) == [1, -1 + sqrt(2), 1 + sqrt(2)]