mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
f8568fbd7f
commit
568511f393
2 changed files with 14 additions and 2 deletions
|
@ -9048,6 +9048,10 @@ lex_global_variable(pm_parser_t *parser) {
|
||||||
return PM_TOKEN_GLOBAL_VARIABLE;
|
return PM_TOKEN_GLOBAL_VARIABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// True if multiple characters are allowed after the declaration of the
|
||||||
|
// global variable. Not true when it starts with "$-".
|
||||||
|
bool allow_multiple = true;
|
||||||
|
|
||||||
switch (*parser->current.end) {
|
switch (*parser->current.end) {
|
||||||
case '~': // $~: match-data
|
case '~': // $~: match-data
|
||||||
case '*': // $*: argv
|
case '*': // $*: argv
|
||||||
|
@ -9106,6 +9110,7 @@ lex_global_variable(pm_parser_t *parser) {
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
parser->current.end++;
|
parser->current.end++;
|
||||||
|
allow_multiple = false;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default: {
|
default: {
|
||||||
size_t width;
|
size_t width;
|
||||||
|
@ -9113,7 +9118,7 @@ lex_global_variable(pm_parser_t *parser) {
|
||||||
if ((width = char_is_identifier(parser, parser->current.end)) > 0) {
|
if ((width = char_is_identifier(parser, parser->current.end)) > 0) {
|
||||||
do {
|
do {
|
||||||
parser->current.end += width;
|
parser->current.end += width;
|
||||||
} while (parser->current.end < parser->end && (width = char_is_identifier(parser, parser->current.end)) > 0);
|
} while (allow_multiple && parser->current.end < parser->end && (width = char_is_identifier(parser, parser->current.end)) > 0);
|
||||||
} else if (pm_char_is_whitespace(peek(parser))) {
|
} else if (pm_char_is_whitespace(peek(parser))) {
|
||||||
// If we get here, then we have a $ followed by whitespace,
|
// If we get here, then we have a $ followed by whitespace,
|
||||||
// which is not allowed.
|
// which is not allowed.
|
||||||
|
|
|
@ -87,7 +87,14 @@ module Prism
|
||||||
|
|
||||||
# Compare against Ruby's expectation.
|
# Compare against Ruby's expectation.
|
||||||
if defined?(RubyVM::InstructionSequence)
|
if defined?(RubyVM::InstructionSequence)
|
||||||
expected = RubyVM::InstructionSequence.compile(source).eval.encoding
|
previous = $VERBOSE
|
||||||
|
expected =
|
||||||
|
begin
|
||||||
|
$VERBOSE = nil
|
||||||
|
RubyVM::InstructionSequence.compile(source).eval.encoding
|
||||||
|
ensure
|
||||||
|
$VERBOSE = previous
|
||||||
|
end
|
||||||
assert_equal expected, actual
|
assert_equal expected, actual
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue