Fix if logic error

ifs may have an empty true block
Especially for unlesses thet is normal, so allow
This commit is contained in:
Torsten Ruger
2019-03-05 20:30:24 +02:00
parent 9bd2195a15
commit 11c5389e24
3 changed files with 10 additions and 7 deletions

View File

@ -23,7 +23,7 @@ module Ruby
def to_vool
cond , rest = *normalize_name(@condition)
me = Vool::IfStatement.new(cond.to_vool , @if_true.to_vool, @if_false&.to_vool)
me = Vool::IfStatement.new(cond.to_vool , @if_true&.to_vool, @if_false&.to_vool)
return me unless rest
Vool::Statements.new([ rest.to_vool , me])
end
@ -37,7 +37,8 @@ module Ruby
end
def to_s(depth = 0)
parts = ["if(#{@condition})" , @if_true.to_s(depth + 1) ]
parts = ["if(#{@condition})" ]
parts << @if_true.to_s(depth + 1) if(@if_true)
parts += ["else" , @if_false.to_s(depth + 1)] if(@if_false)
parts << "end"
at_depth(depth , *parts )