From 51afe63d0bf22f18b5d520dd3ec36da5130c29da Mon Sep 17 00:00:00 2001 From: Venkatesh-Prasad Ranganath Date: Sat, 28 Dec 2024 18:20:19 -0600 Subject: [PATCH] Format code fragments/references in the error message --- spec/std/enumerable_spec.cr | 14 ++++++++------ src/enumerable.cr | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/spec/std/enumerable_spec.cr b/spec/std/enumerable_spec.cr index 09d89ddcdf6d..baffa410110e 100644 --- a/spec/std/enumerable_spec.cr +++ b/spec/std/enumerable_spec.cr @@ -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 @@ -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 diff --git a/src/enumerable.cr b/src/enumerable.cr index 0e87867b28dd..df0e3b9c5652 100644 --- a/src/enumerable.cr +++ b/src/enumerable.cr @@ -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