Skip to content

Commit

Permalink
Merge pull request sass#1731 from xzyfer/fix/min-max-error
Browse files Browse the repository at this point in the history
Fix error messages for `min` and `max`
  • Loading branch information
xzyfer committed Nov 13, 2015
2 parents 56b1c58 + 5c0e19a commit b799509
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,11 +1129,15 @@ namespace Sass {
Signature min_sig = "min($numbers...)";
BUILT_IN(min)
{
To_String to_string(&ctx);
List* arglist = ARG("$numbers", List);
Number* least = 0;
for (size_t i = 0, L = arglist->length(); i < L; ++i) {
Number* xi = dynamic_cast<Number*>(arglist->value_at_index(i));
if (!xi) error("`" + std::string(sig) + "` only takes numeric arguments", pstate);
Expression* val = arglist->value_at_index(i);
Number* xi = dynamic_cast<Number*>(val);
if (!xi) {
error("\"" + val->perform(&to_string) + "\" is not a number for `min'", pstate);
}
if (least) {
if (Eval::lt(xi, least)) least = xi;
} else least = xi;
Expand All @@ -1144,11 +1148,15 @@ namespace Sass {
Signature max_sig = "max($numbers...)";
BUILT_IN(max)
{
To_String to_string(&ctx);
List* arglist = ARG("$numbers", List);
Number* greatest = 0;
for (size_t i = 0, L = arglist->length(); i < L; ++i) {
Number* xi = dynamic_cast<Number*>(arglist->value_at_index(i));
if (!xi) error("`" + std::string(sig) + "` only takes numeric arguments", pstate);
Expression* val = arglist->value_at_index(i);
Number* xi = dynamic_cast<Number*>(val);
if (!xi) {
error("\"" + val->perform(&to_string) + "\" is not a number for `max'", pstate);
}
if (greatest) {
if (Eval::lt(greatest, xi)) greatest = xi;
} else greatest = xi;
Expand Down

0 comments on commit b799509

Please sign in to comment.