Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
Recognize more language constructs: regexp, dstr, yield (fixes #173).
Browse files Browse the repository at this point in the history
Of course, (regexp ...) (dstr ...) and (yield) are actually pretty common.
The virtual machine has ignored these constructs but it has worked
in most cases because child nodes provided the value.

```rb
puts //            # (regexp (regopt))
/foo/i             # (regexp (str "foo") (regopt :i))
puts <<EOS         # (dstr)
EOS
puts "foo#{bar}"   # (dstr (str "foo") (begin (send nil :bar)))
```
  • Loading branch information
mvidner committed Jun 27, 2016
1 parent ef9edf2 commit 6f2de63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ruby-lint/variable_predicates.rb
Expand Up @@ -20,6 +20,7 @@ module VariablePredicates
#
RUBY_CLASSES = {
:str => 'String',
:dstr => 'String',
:sym => 'Symbol',
:int => 'Fixnum',
:float => 'Float',
Expand Down
9 changes: 9 additions & 0 deletions lib/ruby-lint/virtual_machine.rb
Expand Up @@ -103,7 +103,9 @@ class VirtualMachine < Iterator
:int,
:float,
:str,
:dstr,
:sym,
:regexp,
:true,
:false,
:nil,
Expand Down Expand Up @@ -448,6 +450,13 @@ def on_self
push_value(method.return_value)
end

##
# Pushes the return value of the block yielded to, that is, an unknown one.
#
def on_yield
push_unknown_value
end

##
# Creates the definition for a module.
#
Expand Down

0 comments on commit 6f2de63

Please sign in to comment.