Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/typeprof/core/ast/call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initialize(raw_node, recv, mid, mid_code_range, raw_args, last_arg, raw_bloc
@splat_flags << false
end
end
@positional_args = args.map {|arg| arg ? AST.create_node(arg, lenv) : DummyNilNode.new(code_range, lenv) }
@positional_args = args.map {|arg| arg ? AST.create_node(arg, lenv) : nil }

kw = @positional_args.last
if kw.is_a?(TypeProf::Core::AST::HashNode) && kw.keywords
Expand Down Expand Up @@ -119,7 +119,7 @@ def install0(genv)
keyword_args = forward_a_args.keywords
else
positional_args = @positional_args.map do |arg|
if arg.is_a?(DummyNilNode)
if arg.nil?
@lenv.get_var(:"*anonymous_rest")
else
arg.install(genv)
Expand Down
4 changes: 2 additions & 2 deletions lib/typeprof/core/ast/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def initialize(raw_node, lenv, keywords)
if raw_elem.value
@vals << AST.create_node(raw_elem.value, lenv)
else
@vals << DummyNilNode.new(code_range, lenv)
@vals << nil
end
@splat = true
else
Expand Down Expand Up @@ -306,7 +306,7 @@ def install0(genv)
all_symbol_keys = false
end
else
if val.is_a?(DummyNilNode)
if val.nil?
h = @lenv.get_var(:"**anonymous_keyword")
else
h = val.install(genv)
Expand Down
33 changes: 33 additions & 0 deletions scenario/misc/parens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,49 @@ def with_default(x = ())
x
end

def in_array
[()]
end

def in_condition
if (); 1; end
end

def take_arg(x); x; end

def empty_as_arg
take_arg(())
end

def empty_as_splat_arg
take_arg(*())
end

def empty_as_kw_splat
{ **() }
end

grouping
nested
empty
with_default
with_default(1)
in_array
in_condition
empty_as_arg
empty_as_splat_arg
empty_as_kw_splat

## assert
class Object
def grouping: -> Integer
def nested: -> Integer
def empty: -> nil
def with_default: (?Integer?) -> Integer?
def in_array: -> [nil]
def in_condition: -> Integer?
def take_arg: (nil) -> nil
def empty_as_arg: -> nil
def empty_as_splat_arg: -> nil
def empty_as_kw_splat: -> Hash[untyped, untyped]
end
Loading