You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using jruby-parser to rewrite code, but with some code is has some problems:
This:
require 'jruby-parser'
root = JRubyParser.parse( %q{
def log(severity)
case severity
when Severity::DEBUG
@logging_services.debug(msg.to_s)
when Severity::INFO
@logging_services.info(msg.to_s)
when Severity::WARNING
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s)
end
end
} )
root.to_source
produces:
def log severity
case severity[
when Severity
@logging_services.debug(msg.to_s)
when Severity
@logging_services.info(msg.to_s)
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s),
when Severity
@logging_services.info(msg.to_s)
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s),
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s)]
end
end
Can I do something to avoid this behaviour?
The text was updated successfully, but these errors were encountered:
rewriter definitely is broken in this case. It looks like two bugs in fact. All whens get the same 'else' added and also each case is only calling the first part of the constant (also referred to as Colon2 in this case).
I am using jruby-parser to rewrite code, but with some code is has some problems:
This:
require 'jruby-parser'
root = JRubyParser.parse( %q{
def log(severity)
case severity
when Severity::DEBUG
@logging_services.debug(msg.to_s)
when Severity::INFO
@logging_services.info(msg.to_s)
when Severity::WARNING
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s)
end
end
} )
root.to_source
produces:
def log severity
case severity[
when Severity
@logging_services.debug(msg.to_s)
when Severity
@logging_services.info(msg.to_s)
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s),
when Severity
@logging_services.info(msg.to_s)
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s),
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s)]
end
end
Can I do something to avoid this behaviour?
The text was updated successfully, but these errors were encountered: