Problem with ternary operator within Expression

Issue #458 resolved
Florian Bruckner created an issue

hi, using the ternary operator within an Expression leads to compile errors in some cases. See the following example.

from dolfin import *
f1 = Expression("(x[0]<2.0)?1.2:-11.0") # works
f2 = Expression("(x[0]<2.0)?1.2:-10.0") # works
f3 = Expression("(x[0]<2.0)?1.0:1.0")   # fails
f4 = Expression("(x[0]<2.0)?1.0:10.0")  # fails

If braces are placed around the numbers the problem vanishes. Seems that the number without - sign after the : is interpreted as a parameter!?

Comments (8)

  1. Chris Richardson

    @blechta - Jan, I'm not quite sure what happened there... I was just merging my changes into next, which I hadn't touched for a while. I hope I haven't screwed anything up...

  2. Log in to comment