Closed NathanLovato closed 4 years ago
I don't believe this is an issue with the ternary operator in particular, but rather the space between the -
and the 1
at the end. Here are is the tree for your line var direction = 1 if i % 2 == 0 else - 1
start
class_var_stmt
var_assigned
direction
expr
test_expr
1
if
comparison
mdr_expr
i
%
2
==
0
else
neg_expr
-
1
And the tree for var direction = 1 if i % 2 == 0 else - 1
start
class_var_stmt
var_assigned
direction
expr
test_expr
1
if
comparison
mdr_expr
i
%
2
==
0
else
-1
And the error is thrown because these aren't the same, specifically at the very end. This is still an issue, however. In the engine, var a = - 1
would set a to -1. On the other hand, the formatter throws the original error with just this snippet.
Soon I'm going to clean up backlog a bit, I'll cover that.
@Scony just want to check, was this moved to another issue?
@AngelOnFira no, it was closed in b64cf43 - it's not released yet tho. If want to test it, you can pip-install straight from master's HEAD like this: https://adamj.eu/tech/2019/03/11/pip-install-from-a-git-repository/
Here's a line that causes errors:
Traceback