Skip to content

Commit

Permalink
Format code fragments/references in the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
rvprasad committed Dec 29, 2024
1 parent 2dd0012 commit 51afe63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions spec/std/enumerable_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1373,9 +1373,10 @@ describe "Enumerable" do
require "prelude"
[1, 10000000000_u64].sum
CRYSTAL
"Enumerable#sum() and #product() do not support Union types. " +
"Instead, use Enumerable#sum(initial) and #product(initial), " +
"respectively, with an initial value of the intended type of the call."
"`Enumerable#sum()` and `#product()` do not support Union " +
"types. Instead, use `Enumerable#sum(initial)` and " +
"`#product(initial)`, respectively, with an initial value " +
"of the intended type of the call."
end

it "uses additive_identity from type" do
Expand Down Expand Up @@ -1427,9 +1428,10 @@ describe "Enumerable" do
require "prelude"
[1, 10000000000_u64].product
CRYSTAL
"Enumerable#sum() and #product() do not support Union types. " +
"Instead, use Enumerable#sum(initial) and #product(initial), " +
"respectively, with an initial value of the intended type of the call."
"`Enumerable#sum()` and `#product()` do not support Union " +
"types. Instead, use `Enumerable#sum(initial)` and " +
"`#product(initial)`, respectively, with an initial value " +
"of the intended type of the call."
end
end

Expand Down
8 changes: 4 additions & 4 deletions src/enumerable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2299,10 +2299,10 @@ module Enumerable(T)
def self.first
{% if X.union? %}
{{
raise("Enumerable#sum() and #product() do not support Union types. " +
"Instead, use Enumerable#sum(initial) and #product(initial), " +
"respectively, with an initial value of the intended type " +
"of the call.")
raise("`Enumerable#sum()` and `#product()` do not support Union " +
"types. Instead, use `Enumerable#sum(initial)` and " +
"`#product(initial)`, respectively, with an initial value " +
"of the intended type of the call.")
}}
{% else %}
X
Expand Down

0 comments on commit 51afe63

Please sign in to comment.