diff options
-rw-r--r-- | compile.c | 11 | ||||
-rw-r--r-- | eval.c | 7 | ||||
-rw-r--r-- | node.h | 2 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_method.rb | 1 |
5 files changed, 18 insertions, 5 deletions
@@ -4599,7 +4599,16 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath) } } -#define private_recv_p(node) (nd_type((node)->nd_recv) == NODE_SELF) +static inline int +private_recv_p(const NODE *node) +{ + if (nd_type(node->nd_recv) == NODE_SELF) { + NODE *self = node->nd_recv; + return self->nd_state != 0; + } + return 0; +} + static void defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, LABEL **lfinish, VALUE needstr); @@ -189,13 +189,15 @@ rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex) volatile VALUE errs[2] = { Qundef, Qundef }; int nerr; rb_thread_t *th = rb_ec_thread_ptr(ec); + rb_thread_t *volatile const th0 = th; volatile int sysex = EXIT_SUCCESS; volatile int step = 0; rb_threadptr_interrupt(th); rb_threadptr_check_signal(th); EC_PUSH_TAG(ec); - if ((state = EC_EXEC_TAG()) == TAG_NONE) { + th = th0; + if ((state = EC_EXEC_TAG(), th = th0, state) == TAG_NONE) { SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(ec); }); step_0: step++; @@ -548,10 +550,9 @@ static void setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause) { VALUE e; - const char *file = 0; int line; + const char *const file = rb_source_location_cstr(&line); - file = rb_source_location_cstr(&line); if ((file && !NIL_P(mesg)) || (cause != Qundef)) { volatile int state = 0; @@ -369,7 +369,7 @@ typedef struct RNode { #define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc) #define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc) #define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc) -#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,0,loc) +#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,1,loc) #define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc) #define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc) #define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc) @@ -2595,6 +2595,7 @@ primary : literal | tLPAREN_ARG stmt {SET_LEX_STATE(EXPR_ENDARG);} rparen { /*%%%*/ + if (nd_type($2) == NODE_SELF) $2->nd_state = 0; $$ = $2; /*% %*/ /*% ripper: paren!($2) %*/ @@ -2602,6 +2603,7 @@ primary : literal | tLPAREN compstmt ')' { /*%%%*/ + if (nd_type($2) == NODE_SELF) $2->nd_state = 0; $$ = $2; /*% %*/ /*% ripper: paren!($2) %*/ diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index a8064c47c2..a141202014 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -674,6 +674,7 @@ class TestMethod < Test::Unit::TestCase assert_nothing_raised { self.mv1 } assert_nothing_raised { self.mv2 } + assert_raise(NoMethodError) { (self).mv2 } assert_nothing_raised { self.mv3 } v = Visibility.new |