Fix if logic error
ifs may have an empty true block Especially for unlesses thet is normal, so allow
This commit is contained in:
@ -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 )
|
||||
|
@ -16,7 +16,7 @@ module Ruby
|
||||
end
|
||||
|
||||
# This RubyCompiler compiles incoming ruby (string) into a typed
|
||||
# version of theast, with the help of the parser gem.
|
||||
# version of the ast, with the help of the parser gem.
|
||||
# The parser outputs an abstract ast (nodes)
|
||||
# that get transformed into concrete, specific classes.
|
||||
#
|
||||
|
Reference in New Issue
Block a user