Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1b2f19a

Browse files
authored
Merge pull request #208 from ruby-syntax-tree/fix-toregexp
Fix implementing toregexp
2 parents f9835e4 + 72e5273 commit 1b2f19a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/syntax_tree/visitor/compiler.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,11 @@ def topn(number)
750750
iseq.push([:topn, number])
751751
end
752752

753+
def toregexp(options, length)
754+
stack.change_by(-length + 1)
755+
iseq.push([:toregexp, options, length])
756+
end
757+
753758
private
754759

755760
# This creates a call data object that is used as the operand for the

test/compiler_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ class CompilerTest < Minitest::Test
270270
"{ foo => bar, baz => qux }",
271271
"%s[foo]",
272272
"[$1, $2, $3, $4, $5, $6, $7, $8, $9]",
273+
"/foo \#{bar} baz/",
274+
"%r{foo \#{bar} baz}",
273275
# Core method calls
274276
"alias foo bar",
275277
"alias :foo :bar",

0 commit comments

Comments
 (0)