summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c11
-rw-r--r--eval.c7
-rw-r--r--node.h2
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_method.rb1
5 files changed, 18 insertions, 5 deletions
diff --git a/compile.c b/compile.c
index 368a69853d..51b7b9fc3c 100644
--- a/compile.c
+++ b/compile.c
@@ -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);
diff --git a/eval.c b/eval.c
index 5d402e5cb8..c548c34b68 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/node.h b/node.h
index a493dfa123..276b4d419c 100644
--- a/node.h
+++ b/node.h
@@ -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)
diff --git a/parse.y b/parse.y
index 03db19f2cf..a51328cdce 100644
--- a/parse.y
+++ b/parse.y
@@ -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