diff --git a/node.go b/node.go index 9fb2cf8..d330bf0 100644 --- a/node.go +++ b/node.go @@ -1090,6 +1090,25 @@ func (this *conversionState) convertNoFreeFloating(n_ node.Node) (string, error) return "!(" + rhs + ")", nil + case *expr.Ternary: + cond, err := this.convert(n.Condition) + if err != nil { + return "", parseErr{n, err} + } + + iftrue, err := this.convert(n.IfTrue) + if err != nil { + return "", parseErr{n, err} + } + + iffalse, err := this.convert(n.IfFalse) + if err != nil { + return "", parseErr{n, err} + } + + // FIXME this is (A) not idiomatic, and (B) doesn't work in assignment expressions + return "(func() unknown {\nif (" + cond + ") {\nreturn (" + iftrue + ")\n} else {\nreturn (" + iffalse + ")\n } })()", nil + case *expr.ArrayDimFetch: // Might be x[foo], might be x[] (i.e. append() call) // In order to make the append() transformation, we need to lookahead