diff options
author | Kevin Newton <[email protected]> | 2024-10-03 13:33:14 -0400 |
---|---|---|
committer | git <[email protected]> | 2024-10-03 17:43:11 +0000 |
commit | 568511f3937502aa84a33f321508bd2cda652303 () | |
tree | fa8c550cb6ec3a0515195a7c4cdd26a8100ee271 | |
parent | f8568fbd7f87f749de46abc6ce07b9d3e0c6b40d (diff) |
[ruby/prism] Handle single global variable character name
https://.com/ruby/prism/commit/7a0af49997
-rw-r--r-- | prism/prism.c | 7 | ||||
-rw-r--r-- | test/prism/magic_comment_test.rb | 9 |
2 files changed, 14 insertions, 2 deletions
@@ -9048,6 +9048,10 @@ lex_global_variable(pm_parser_t *parser) { return PM_TOKEN_GLOBAL_VARIABLE; } switch (*parser->current.end) { case '~': // $~: match-data case '*': // $*: argv @@ -9106,6 +9110,7 @@ lex_global_variable(pm_parser_t *parser) { case '-': parser->current.end++; /* fallthrough */ default: { size_t width; @@ -9113,7 +9118,7 @@ lex_global_variable(pm_parser_t *parser) { if ((width = char_is_identifier(parser, parser->current.end)) > 0) { do { parser->current.end += width; - } while (parser->current.end < parser->end && (width = char_is_identifier(parser, parser->current.end)) > 0); } else if (pm_char_is_whitespace(peek(parser))) { // If we get here, then we have a $ followed by whitespace, // which is not allowed. @@ -87,7 +87,14 @@ module Prism # Compare against Ruby's expectation. if defined?(RubyVM::InstructionSequence) - expected = RubyVM::InstructionSequence.compile(source).eval.encoding assert_equal expected, actual end end |