Skip to content

Commit

Permalink
Fix: type var that resolves to number in restriction didn't work (#6504)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored and bcardiff committed Aug 8, 2018
1 parent 0ff17f1 commit cd8334d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions spec/compiler/semantic/generic_class_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1063,4 +1063,17 @@ describe "Semantic: generic class" do
),
"undefined constant T"
end

it "can use type var that resolves to number in restriction (#6502)" do
assert_type(%(
class Foo(N)
def foo : Foo(N)
self
end
end
f = Foo(1).new
f.foo
)) { generic_class "Foo", 1.int32 }
end
end
6 changes: 3 additions & 3 deletions src/compiler/crystal/semantic/type_lookup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ class Crystal::Type
type_var.raise "expanding constant value for a number value", inner: ex
end
next
# when ASTNode
# type_vars << type
# next
when ASTNode
type_vars << type
next
end
end

Expand Down

0 comments on commit cd8334d

Please sign in to comment.