diff options
author | Marius Kintel <marius@kintel.net> | 2011-10-23 20:33:11 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-10-23 20:33:11 (GMT) |
commit | 7d9104e748aaf9f54a490a8ca143d2864ddb61d3 (patch) | |
tree | a2060336df9382bb7db83819af398903c18b2af5 /src/expr.cc | |
parent | 3366403d1df0cdf4f633194e9d2564756381763c (diff) |
Evaluate expressions for the ternary operator the same way as for if-else, i.e. cast any value to bool
Diffstat (limited to 'src/expr.cc')
-rw-r--r-- | src/expr.cc | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/expr.cc b/src/expr.cc index c9eda4e..fc1fbf0 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -75,9 +75,7 @@ Value Expression::evaluate(const Context *context) const return this->children[0]->evaluate(context) > this->children[1]->evaluate(context); if (this->type == "?:") { Value v = this->children[0]->evaluate(context); - if (v.type == Value::BOOL) - return this->children[v.b ? 1 : 2]->evaluate(context); - return Value(); + return this->children[v.toBool() ? 1 : 2]->evaluate(context); } if (this->type == "[]") { Value v1 = this->children[0]->evaluate(context); |