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

Properly hydrate numbers after operations in variable assignments #797

Merged
merged 1 commit into from
Jan 3, 2015
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
9 changes: 3 additions & 6 deletions eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,8 @@ namespace Sass {
// behave according to as ruby sass (add leading zero)
if (value->concrete_type() == Expression::NUMBER) {
Number* n = static_cast<Number*>(value);
value = new (ctx.mem) Number(n->path(),
n->position(),
n->value(),
n->unit(),
true);
value = new (ctx.mem) Number(*n);
static_cast<Number*>(value)->zero(true);
}
else if (value->concrete_type() == Expression::STRING) {
String_Constant* s = static_cast<String_Constant*>(value);
Expand Down Expand Up @@ -946,7 +943,7 @@ namespace Sass {
string r_unit(tmp.unit());
if (l_unit != r_unit && !l_unit.empty() && !r_unit.empty() &&
(op == Binary_Expression::ADD || op == Binary_Expression::SUB)) {
error("cannot add or subtract numbers with incompatible units", l->path(), l->position());
error("Incompatible units: '"+r_unit+"' and '"+l_unit+"'.", l->path(), l->position());
}
Number* v = new (ctx.mem) Number(*l);
v->position(b->position());
Expand Down
8 changes: 6 additions & 2 deletions inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,12 @@ namespace Sass {
d.resize(d.length()-1);
}
if (d[d.length()-1] == '.') d.resize(d.length()-1);
if (n->numerator_units().size() > 1 || n->denominator_units().size() > 0) {
error(d + n->unit() + " is not a valid CSS value", n->path(), n->position());
if (n->numerator_units().size() > 1 ||
n->denominator_units().size() > 0 ||
(n->numerator_units().size() && n->numerator_units()[0].find_first_of('/') != string::npos) ||
(n->numerator_units().size() && n->numerator_units()[0].find_first_of('*') != string::npos)
) {
error(d + n->unit() + " isn't a valid CSS value.", n->path(), n->position());
}
if (!n->zero()) {
if (d.substr(0, 3) == "-0.") d.erase(1, 1);
Expand Down