Bug #9038

instance_eval throws RuntimeError for bad syntax (regression from 2.0.0)

Added by André Arko over 1 year ago. Updated 12 months ago.

[ruby-core:57949]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 2.1.0dev (2013-10-20 trunk 43373) [x86_64-linux] Backport:1.9.3: UNKNOWN, 2.0.0: DONE

Description

In Ruby 2.1.0dev (2013-10-20 trunk 43373), instance_eval throws a RuntimeError when it should throw a SyntaxError, but only the first time it is called. If you use an IRB session to call instance_eval a second time with the exact same arguments, it produces the expected SyntaxError instead of .

Here is an example: ruby -e "instance_eval('/unquoted/string/syntax/error')"

That example raises a SyntaxError on Ruby 2.0.0p247, but raises a RuntimeError on 2.1.0dev (2013-10-20 trunk 43373).

error.rb Magnifier (30 Bytes) André Arko, 10/21/2013 03:22 PM

Associated revisions

Revision 43376
Added by Nobuyoshi Nakada over 1 year ago

encoding.c: preserve outer errinfo

  • encoding.c (load_encoding): should preserve outer errinfo, so that expected exception may not be lost. [Bug #9038]

Revision 43376
Added by Nobuyoshi Nakada over 1 year ago

encoding.c: preserve outer errinfo

  • encoding.c (load_encoding): should preserve outer errinfo, so that expected exception may not be lost. [Bug #9038]

History

#1 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43376.
André, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


encoding.c: preserve outer errinfo

  • encoding.c (load_encoding): should preserve outer errinfo, so that expected exception may not be lost. [Bug #9038]

#2 Updated by Tomoyuki Chikanaga over 1 year ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: REQUIRED

Even though this issue is not reproducible with 2.0.0, the same flaw exists on ruby_2_0_0. I'll backport r43376 to fix a potential bug.

#3 Updated by Tomoyuki Chikanaga over 1 year ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: REQUIRED to 1.9.3: UNKNOWN, 2.0.0: DONE

r43376 is backported to ruby_2_0_0 branch at r43414. I modify test code not to use new assertion of Test::Unit.

#4 Updated by Nobuyoshi Nakada 12 months ago

  • Description updated (diff)

Also available in: Atom PDF