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

Improve too big tuple and named tuple error message #7131

Merged
merged 7 commits into from Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion spec/compiler/semantic/tuple_spec.cr
Expand Up @@ -287,7 +287,18 @@ describe "Semantic: tuples" do
pos += {0, 0}
end
),
"tuple too big"
"tuple size cannot be greater than 300 (size is 301)"
end

it "errors on named tuple too big" do
assert_error %(
{ #{String.build do |io|
straight-shoota marked this conversation as resolved.
Show resolved Hide resolved
333.times do |i|
io << "arg" << i << ": 0, "
end
end} }
),
"named tuple size cannot be greater than 300 (size is 333)"
end

it "doesn't unify tuple metaclasses (#5384)" do
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/crystal/semantic/bindings.cr
Expand Up @@ -519,7 +519,7 @@ module Crystal
end

if types.size > 300
raise "tuple too big: Tuple(#{types[0...10].join(',')}, ...)"
raise "tuple size cannot be greater than 300 (size is #{types.size})"
end

self.type = tuple_type
Expand All @@ -543,7 +543,7 @@ module Crystal
end

if entries.size > 300
raise "named tuple too big: #{named_tuple_type}"
raise "named tuple size cannot be greater than 300 (size is #{entries.size})"
end

self.type = named_tuple_type
Expand Down