Skip to content

Commit

Permalink
Fixes stylus#698: incorrect function call within for with named argument
Browse files Browse the repository at this point in the history
  • Loading branch information
tonistiigi committed May 28, 2012
1 parent 76e3d3b commit c40251a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/visitor/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,11 @@ Evaluator.prototype.visitCall = function(call){

// Evaluate arguments
this.return++;
var args = this.visit(call.args);
for (var key in call.args.map) {
call.args.map[key] = this.visit(call.args.map[key]);
var args = this.visit(call.args)
, mapCopy = {};
for (var key in args.map) {
mapCopy[key] = args.map[key];
args.map[key] = this.visit(mapCopy[key].clone());
}
this.return--;

Expand All @@ -342,6 +344,9 @@ Evaluator.prototype.visitCall = function(call){
ret = this.invokeFunction(fn, args);
}

for (key in mapCopy) {
args.map[key] = mapCopy[key];
}
this.calling.pop();
this.ignoreColors = false;
return ret;
Expand Down
5 changes: 5 additions & 0 deletions test/cases/for.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ body foo {
body foo {
bar: 3;
}
body {
bar: 1;
bar: 2;
bar: 3;
}
body foo bar {
baz: 1;
}
Expand Down
7 changes: 7 additions & 0 deletions test/cases/for.styl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ body
for n in 1 2 3
foo
bar n

func(num)
return num

body
for n in 1 2 3
bar func(num: n)

test(args...)
foo
Expand Down

0 comments on commit c40251a

Please sign in to comment.