Skip to content

Commit efadc96

Browse files
committed
Don't connect DummyNilNode when there's no else clause
1 parent 0cc75e0 commit efadc96

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/typeprof/core/ast/control.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ def initialize(raw_node, lenv)
366366
end
367367
raw_res = raw_res.subsequent
368368
end
369-
@else_clause = raw_node.else_clause&.statements ? AST.create_node(raw_node.else_clause.statements, lenv) : DummyNilNode.new(code_range, lenv)
370-
@ensure_clause = raw_node.ensure_clause&.statements ? AST.create_node(raw_node.ensure_clause.statements, lenv) : DummyNilNode.new(code_range, lenv)
369+
@else_clause = AST.create_node(raw_node.else_clause.statements, lenv) if raw_node.else_clause&.statements
370+
@ensure_clause = AST.create_node(raw_node.ensure_clause.statements, lenv) if raw_node.ensure_clause&.statements
371371
end
372372

373373
attr_reader :body, :rescue_conds, :rescue_clauses, :else_clause, :ensure_clause

scenario/control/begin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def foo
99

1010
## assert
1111
class Object
12-
def foo: -> (Integer | String)?
12+
def foo: -> (Integer | String)
1313
end
1414

1515
## update
@@ -23,7 +23,7 @@ def foo
2323

2424
## assert
2525
class Object
26-
def foo: -> Integer?
26+
def foo: -> Integer
2727
end
2828

2929

scenario/control/ensure.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ def foo(n)
1515
## assert
1616
class Object
1717
def bar: (String) -> nil
18-
def foo: (Integer) -> Float?
18+
def foo: (Integer) -> Float
1919
end

0 commit comments

Comments
 (0)