Skip to content

Commit

Permalink
* compile.c (iseq_compile_each): should handle upper level eval iseq
Browse files Browse the repository at this point in the history
  from break/next, and COMPILE_ERROR() breaks only one block.
  [ruby-dev:31372]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 19, 2007
1 parent 5e8e08d commit a927483
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Thu Dec 20 01:10:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>

* compile.c (iseq_compile_each): should handle upper level eval iseq
from break/next, and COMPILE_ERROR() breaks only one block.
[ruby-dev:31372]

Thu Dec 20 00:07:36 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>

* test/drb/drbtest.rb (test_07_public_private_protected_missing):
Expand Down
13 changes: 9 additions & 4 deletions bootstraptest/test_eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ def initialize &b
$ans
}

assert_match /Illegal break/, %q{
STDERR.reopen(STDOUT)
eval "0 rescue break"
}, '[ruby-dev:31372]'
%w[break next redo].each do |keyword|
assert_match %r"Can't escape from eval with #{keyword}\z", %{
begin
eval "0 rescue #{keyword}"
rescue SyntaxError => e
e.message
end
}, '[ruby-dev:31372]'
end
13 changes: 11 additions & 2 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2942,11 +2942,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
INT2FIX(level | 0x02) /* TAG_BREAK */ );
}
else if (iseq->type == ISEQ_TYPE_EVAL) {
break_in_eval:
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with break"));
}
else {
rb_iseq_t *ip = iseq->parent_iseq;
while (ip && ip->compile_data) {
while (ip) {
level++;
if (ip->compile_data->redo_label != 0) {
level = 0x8000;
Expand All @@ -2960,6 +2961,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
level <<= 16;
goto break_by_insn;
}
else if (ip->type == ISEQ_TYPE_EVAL) {
goto break_in_eval;
}
ip = ip->parent_iseq;
}
COMPILE_ERROR((ERROR_ARGS "Illegal break"));
Expand All @@ -2985,6 +2989,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
iseq->compile_data->end_label);
}
else if (iseq->type == ISEQ_TYPE_EVAL) {
next_in_eval:
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with next"));
}
else {
Expand All @@ -3001,6 +3006,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
level |= 0x4000;
break;
}
else if (ip->type == ISEQ_TYPE_EVAL) {
goto next_in_eval;
}
ip = ip->parent_iseq;
}
if (ip != 0) {
Expand Down Expand Up @@ -3034,6 +3042,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
#endif
}
else if (iseq->type == ISEQ_TYPE_EVAL) {
redo_in_eval:
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with redo"));
}
else if (iseq->compile_data->start_label) {
Expand All @@ -3059,7 +3068,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
break;
}
else if (ip->type == ISEQ_TYPE_EVAL) {
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with redo"));
goto redo_in_eval;
}
ip = ip->parent_iseq;
}
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-12-19"
#define RUBY_RELEASE_DATE "2007-12-20"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20071219
#define RUBY_RELEASE_CODE 20071220
#define RUBY_PATCHLEVEL 0

#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 12
#define RUBY_RELEASE_DAY 19
#define RUBY_RELEASE_DAY 20

#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
Expand Down

0 comments on commit a927483

Please sign in to comment.