Skip to content

Commit

Permalink
Fixed - else bug introduced with new error context stack
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Sep 8, 2011
1 parent c74ad7e commit df6845e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/compiler.js
Expand Up @@ -123,7 +123,7 @@ Compiler.prototype = {
*/ */


visit: function(node){ visit: function(node){
var debug = this.debug && false !== node.debug; var debug = this.debug;


if (debug) { if (debug) {
this.buf.push('__.unshift({ lineno: ' + node.line this.buf.push('__.unshift({ lineno: ' + node.line
Expand All @@ -133,6 +133,13 @@ Compiler.prototype = {
+ ' });'); + ' });');
} }


// Massive hack to fix our context
// stack for - else[ if] etc
if (false === node.debug) {
this.buf.pop();
this.buf.pop();
}

this.visitNode(node); this.visitNode(node);


if (debug) this.buf.push('__.shift();'); if (debug) this.buf.push('__.shift();');
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/code.js
Expand Up @@ -25,7 +25,7 @@ var Code = module.exports = function Code(val, buffer, escape) {
this.val = val; this.val = val;
this.buffer = buffer; this.buffer = buffer;
this.escape = escape; this.escape = escape;
if (/^ *else/.test(val)) this.debug = false; if (val.match(/^ *else/)) this.debug = false;
}; };


/** /**
Expand Down

0 comments on commit df6845e

Please sign in to comment.