diff --git a/pymbolic/parser.py b/pymbolic/parser.py index d0e49cd9b1f967d3c049d000d53f9f6739091a21..cf41b4d3b520ca8e6ac1840797aa349e0fc966cb 100644 --- a/pymbolic/parser.py +++ b/pymbolic/parser.py @@ -197,6 +197,12 @@ class Parser(object): return complex(pstate.next_str_and_advance()) elif next_tag is _identifier: return primitives.Variable(pstate.next_str_and_advance()) + elif next_tag is _if: + from warnings import warn + warn("Usage of 'if' as an identifier is deprecated due to" + " introduction of python style 'if-else' expressions.", + DeprecationWarning, stacklevel=2) + return primitives.Variable(pstate.next_str_and_advance()) else: pstate.expected("terminal") diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index bc8b6edaea329a18e4a87de95ec4a0c0fe67d9e6..0bd708caecc1f13ad19e12113da8a38f3146b693 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -284,6 +284,9 @@ def test_parser(): assert_parsed_same_as_python("0 if 1 if 2 else 3 else 4") assert_parsed_same_as_python("0 if (1 if 2 else 3) else 4") + with pytest.deprecated_call(): + parse('1+if(0, 1, 2)') + # }}}