Skip to content

Commit cbc364d

Browse files
Merge pull request #134 from JuliaDiffEq/hg/fix/ifelse
Convert :if blocks to ifelse calls
2 parents ca0692e + 041c7cb commit cbc364d

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ using MacroTools
22

33

44
function Base.convert(::Type{Expression}, ex::Expr)
5+
ex.head === :if && (ex = Expr(:call, ifelse, ex.args...))
56
ex.head === :call || throw(ArgumentError("internal representation does not support non-call Expr"))
67

78
op = eval(ex.args[1]) # HACK

test/variable_parsing.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ D1 = Differential(t)
3232

3333
@test @macroexpand(@parameters x, y, z(t)) == @macroexpand(@parameters x y z(t))
3434
@test @macroexpand(@variables x, y, z(t)) == @macroexpand(@variables x y z(t))
35+
36+
convert(Expression, :($x == 0 ? $y : $x))

0 commit comments

Comments
 (0)