Skip to content

Commit

Permalink
* parse.y (k_def): adjust the location of method definition to the
Browse files Browse the repository at this point in the history
  line of def.  [Bug ruby#2427]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 4, 2009
1 parent 2c2cf71 commit 9ad0653
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Fri Dec 4 16:50:13 2009 Nobuyoshi Nakada <[email protected]>

* parse.y (k_def): adjust the location of method definition to the
line of def. [Bug #2427]

Fri Dec 4 15:50:18 2009 Shugo Maeda <[email protected]>

* vm_eval.c (yield_under): does not yield self, and passes blockptr
Expand Down
8 changes: 6 additions & 2 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -2902,7 +2902,7 @@ primary : literal
NODE *body = remove_begin($5);
reduce_nodes(&body);
$$ = NEW_DEFN($2, $4, body, NOEX_PRIVATE);
fixpos($$, $4);
nd_set_line($$, $<num>1);
/*%
$$ = dispatch3(def, $2, $4, $5);
%*/
Expand All @@ -2924,7 +2924,7 @@ primary : literal
NODE *body = remove_begin($8);
reduce_nodes(&body);
$$ = NEW_DEFS($2, $5, $7, body);
fixpos($$, $2);
nd_set_line($$, $<num>1);
/*%
$$ = dispatch5(defs, $2, $3, $5, $7, $8);
%*/
Expand Down Expand Up @@ -3034,6 +3034,10 @@ k_module : keyword_module
k_def : keyword_def
{
token_info_push("def");
/*%%%*/
$<num>$ = ruby_sourceline;
/*%
%*/
}
;

Expand Down
7 changes: 4 additions & 3 deletions test/ruby/test_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,15 @@ def test_to_s
assert(x.to_s.tainted?)
end

def source_location_test
__LINE__
@@line_of_source_location_test = __LINE__ + 1
def source_location_test a=1,
b=2
end

def test_source_location
file, lineno = method(:source_location_test).source_location
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
assert_equal(source_location_test - 1, lineno)
assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
end

def test_splat_without_respond_to
Expand Down

0 comments on commit 9ad0653

Please sign in to comment.