Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: type var that resolves to number in restriction didn't work #6504

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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