Skip to content

Commit

Permalink
Compiler: check typeof dependencies before cleanup (#8695)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Jan 17, 2020
1 parent a19efff commit 1292e74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions spec/compiler/semantic/block_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1432,4 +1432,15 @@ describe "Block inference" do
Node.new.sum
)) { int32 }
end

it "doesn't crash on cleaning up typeof node without dependencies (#8669)" do
semantic(%(
def foo(&)
end
foo do
typeof(bar)
end
))
end
end
5 changes: 4 additions & 1 deletion src/compiler/crystal/semantic/cleanup_transformer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,10 @@ module Crystal
node = super

unless node.type?
node.unbind_from node.dependencies
if dependencies = node.dependencies?
node.unbind_from node.dependencies
end

node.bind_to node.expressions
end

Expand Down

0 comments on commit 1292e74

Please sign in to comment.