Skip to content

Commit

Permalink
Compiler: don't match splat restriction by default. Fixes #3698
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Dec 15, 2016
1 parent 02d4db3 commit 0c6cd7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/compiler/semantic/restrictions_spec.cr
Expand Up @@ -397,4 +397,14 @@ describe "Restrictions" do
foo(Parent || Child)
)) { types["Parent"].metaclass.virtual_type! }
end

it "doesn't crash on invalid splat restriction (#3698)" do
assert_error %(
def foo(arg : *String)
end
foo(1)
),
"no overload matches"
end
end
4 changes: 4 additions & 0 deletions src/compiler/crystal/semantic/restrictions.cr
Expand Up @@ -426,6 +426,10 @@ module Crystal
nil
end

def restrict(other : Splat, context)
nil
end

def restrict(other : ASTNode, context)
raise "Bug: unsupported restriction: #{self} vs. #{other}"
end
Expand Down

0 comments on commit 0c6cd7a

Please sign in to comment.