Skip to content

Commit

Permalink
Initialize instance variables before reading them
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinggenius committed Nov 4, 2016
1 parent 30a6806 commit 88041b0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/parslet/atoms/base.rb
Expand Up @@ -137,7 +137,7 @@ def self.precedence(prec)
end
precedence BASE
def to_s(outer_prec=OUTER)
str = @label || to_s_inner(precedence)
str = label || to_s_inner(precedence)
if outer_prec < precedence
"(#{str})"
else
Expand Down
1 change: 1 addition & 0 deletions lib/parslet/atoms/entity.rb
Expand Up @@ -16,6 +16,7 @@ def initialize(name, label=nil, &block)
@name = name
@label = label
@block = block
@parslet = nil
end

def try(source, context, consume_all)
Expand Down
4 changes: 2 additions & 2 deletions lib/parslet/cause.rb
Expand Up @@ -5,8 +5,8 @@ module Parslet
#
class Cause
def initialize(message, source, pos, children)
@message, @source, @pos, @children =
message, source, pos, children
@message, @source, @pos, @children, @context =
message, source, pos, children, nil
end

# @return [String, Array] A string or an array of message pieces that
Expand Down
1 change: 1 addition & 0 deletions lib/parslet/source/line_cache.rb
Expand Up @@ -10,6 +10,7 @@ def initialize
# but probably make a scan to that position neccessary.
@line_ends = []
@line_ends.extend RangeSearch
@last_line_end = nil
end

# Returns a <line, column> tuple for the given input position. Input
Expand Down
2 changes: 1 addition & 1 deletion lib/parslet/transform.rb
Expand Up @@ -131,7 +131,7 @@ def rule(expression, &block)
# Allows accessing the class' rules
#
def rules
@__transform_rules || []
@__transform_rules ||= []
end

def inherited(subclass)
Expand Down

0 comments on commit 88041b0

Please sign in to comment.