xacro:if/unless ${not <variable>}
ndahn opened this issue · comments
I have found a project (line 6) which uses xacro:unless
together with ${not <variable>}
. This is clearly a degenerate case that could be easily resolved, but unfortunately it is still valid syntax. Right now the parser fails on this. I have tried some simple fixes, but it turns out that this problem runs quite deep. Replacing the not
part with an operator (e.g. !
) inside unpackParams
might be an option, but I'm unsure if this would encroach on existing valid syntax.
Yeah I expected this kind of thing to crop up at some point. The core of the issue is that the original "Xacro" spec allows you to write arbitrary python for expressions which is inevitably difficult to be robust to in JS and is where not
comes from. I'm happy to add more functionality to close the gap as issues come up if we can, though.
The expr-eval
package is being used to safely evaluate expressions in this file and it seems pretty impressively extensible. I'm wondering if just adding a not
operator to the unaryOperators object would just work here. Do you want to give that try to see if it works and make a PR with a test if it does? I think this is a good addition.
Fixing this in #57. Looks like using !
actually performed a factorial in expr-eval by default so I've fixed that to perform as expected now, as well.