Skip to content

Commit 0c6cd7a

Browse files
author
Ary Borenszweig
committedDec 15, 2016
Compiler: don't match splat restriction by default. Fixes #3698
1 parent 02d4db3 commit 0c6cd7a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
 

‎spec/compiler/semantic/restrictions_spec.cr

+10
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,14 @@ describe "Restrictions" do
397397
foo(Parent || Child)
398398
)) { types["Parent"].metaclass.virtual_type! }
399399
end
400+
401+
it "doesn't crash on invalid splat restriction (#3698)" do
402+
assert_error %(
403+
def foo(arg : *String)
404+
end
405+
406+
foo(1)
407+
),
408+
"no overload matches"
409+
end
400410
end

‎src/compiler/crystal/semantic/restrictions.cr

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ module Crystal
426426
nil
427427
end
428428

429+
def restrict(other : Splat, context)
430+
nil
431+
end
432+
429433
def restrict(other : ASTNode, context)
430434
raise "Bug: unsupported restriction: #{self} vs. #{other}"
431435
end

0 commit comments

Comments
 (0)
Please sign in to comment.