Skip to content
This repository

Error Messages Seem Different Compared to YARV #1141

Closed
robertsosinski opened this Issue · 3 comments

4 participants

Robert Sosinski Thomas E Enebo Charles Oliver Nutter Hiro Asari
Robert Sosinski

Hi JRuby Folk,

Been tooling around with JRuby, and notice that error messages seem to be aligned differently or have different content then what I'm used to with YARV. Not sure if it is an issue, but thought I'd bring it up must in case.

Example one, trying to change the value of self

Ruby 1.9.3:

irb(main):001:0> self = 42
SyntaxError: (irb):1: Can't change the value of self
self = 42
      ^
  from /Users/rsosinski/.rubies/ruby-1.9.3-p448/bin/irb:12:in `<main>'

JRuby 1.7.5 in 1.9.3 Mode:

irb(main):039:0* self = 42
SyntaxError: (irb):39: Can't change the value of selfself = 42
     ^
  from org/jruby/RubyKernel.java:1121:in `eval'
  from org/jruby/RubyKernel.java:1517:in `loop'
  from org/jruby/RubyKernel.java:1282:in `catch'
  from org/jruby/RubyKernel.java:1282:in `catch'
  from /Users/rsosinski/.rubies/jruby-1.7.5/bin/irb:13:in `(root)'

Notice how the two lines are condensed, making it read "selfself". Also, the carrot ^ is not showing where the error actually is (which should probably be under the equals sign.

Example two, bad lambda syntax:

Ruby 1.9.3:

irb(main):016:0> lamb = lambda do { |a, b| a + b } end
SyntaxError: (irb):16: syntax error, unexpected '|', expecting '}'
lamb = lambda do { |a, b| a + b } end
                    ^
(irb):16: syntax error, unexpected '|', expecting '='
lamb = lambda do { |a, b| a + b } end
                         ^
(irb):16: syntax error, unexpected '}', expecting keyword_end
lamb = lambda do { |a, b| a + b } end
                                 ^
  from /Users/rsosinski/.rubies/ruby-1.9.3-p448/bin/irb:12:in `<main>'

JRuby 1.7.5 in 1.9.3 Mode:

irb(main):057:0> lamb = lambda do { |a, b| a + b } end
SyntaxError: (irb):57: syntax error, unexpected tPIPE

lamb = lambda do { |a, b| a + b } end
                   ^
  from org/jruby/RubyKernel.java:1121:in `eval'
  from org/jruby/RubyKernel.java:1517:in `loop'
  from org/jruby/RubyKernel.java:1282:in `catch'
  from org/jruby/RubyKernel.java:1282:in `catch'
  from /Users/rsosinski/.rubies/jruby-1.7.5/bin/irb:13:in `(root)'

The 1.9.3 version gives some more info, while the JRuby only provides one error.

Not a big deal, just interested in what the ideology is for errors, and if I should expect them to be the same.

Thanks for all the work!

Charles Oliver Nutter
Owner

In general you shouldn't expect errors to be the same, but these look like flawed or missing cases from our parser. Since the parser for JRuby is generally expected to match the parser from MRI, these probably could (and maybe should) be fixed.

Hiro Asari
Owner

The first example is just a formatting error. This is addressed by e29e513 and 7cf0504.

The second example appears a little more profound, requiring some parser work.

Thomas E Enebo
Owner

Yeah I don't think we will likely ever go this extra step of giving what is expected. It is possible to do but there are so many other things to work on and the expecting phrasing usually is near useless. I am inclined to close on this now since the obvious typo was fixed.

Thomas E Enebo enebo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.