Skip to content

Commit

Permalink
[Bug #19549] Check for variables to be interpolated
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 7, 2023
1 parent 05aaff2 commit bd04676
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
18 changes: 2 additions & 16 deletions parse.y
Expand Up @@ -5432,24 +5432,10 @@ string_dend : tSTRING_DEND
| END_OF_INPUT
;

string_dvar : tGVAR
string_dvar : nonlocal_var
{
/*%%%*/
$$ = NEW_GVAR($1, &@$);
/*% %*/
/*% ripper: var_ref!($1) %*/
}
| tIVAR
{
/*%%%*/
$$ = NEW_IVAR($1, &@$);
/*% %*/
/*% ripper: var_ref!($1) %*/
}
| tCVAR
{
/*%%%*/
$$ = NEW_CVAR($1, &@$);
if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
/*% %*/
/*% ripper: var_ref!($1) %*/
}
Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_parse.rb
Expand Up @@ -1443,6 +1443,11 @@ def set(arg)
assert_equal(expected, obj.arg)
end
def test_ungettable_gvar
assert_syntax_error('$01234', /not valid to get/)
assert_syntax_error('"#$01234"', /not valid to get/)
end
=begin
def test_past_scope_variable
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
Expand Down

0 comments on commit bd04676

Please sign in to comment.