summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-05-28 03:23:52 +0900
committeraycabta <aycabta@gmail.com>2019-05-28 03:23:52 +0900
commit5e275dd2af4d9d24cdb1cfc0f232f348dae9c2cd (patch)
tree04d0b318b21cefd6246542ef22f23a533a7d52bc /lib
parent7447c7b651d9074879429bb84dd73f8821521f27 (diff)
Treat :@1, :@@1, @1, and @@1 correctly to check termination
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/ruby-lex.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 4121fa1f7c..b3985fb838 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -136,6 +136,15 @@ class RubyLex
return false
elsif @tokens.size >= 2 and @tokens[-2][1] == :on_kw and (@tokens[-2][2] == 'begin' or @tokens[-2][2] == 'else')
return false
+ elsif @tokens.size >= 3 and @tokens[-3][1] == :on_symbeg and @tokens[-2][1] == :on_ivar
+ # This is for :@a or :@1 because :@1 ends with EXPR_FNAME
+ return false
+ elsif @tokens.size >= 2 and @tokens[-2][1] == :on_ivar and @tokens[-2][2] =~ /\A@\d+\z/
+ # This is for @1
+ return false
+ elsif @tokens.size >= 2 and @tokens[-2][1] == :on_cvar and @tokens[-1][1] == :on_int
+ # This is for @@1 or :@@1 and ends with on_int because it's syntax error
+ return false
elsif !@tokens.empty? and @tokens.last[2] == "\\\n"
return true
elsif @tokens.size >= 2 and @tokens[-2][3].anybits?(continued_bits)
@@ -199,6 +208,12 @@ class RubyLex
# example:
# method / f /
return false
+ when /numbered parameter outside block/
+ # "numbered parameter outside block"
+ #
+ # example:
+ # :@1
+ return false
end
ensure
$VERBOSE = verbose