Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed: blank file as input produces invalid javascript file #34

Merged
merged 1 commit into from

2 participants

@sktaylor
Collaborator

Running tamejs on an empty file, produced an invalid javascript file. Notice the call to "undefined" as a function on the last line. Now it calls an anonymous function.

Output Was:

var tame = require('tamejs').runtime;

var __tame_defer_cb = null;
undefined (tame.end);

Output Is:

var tame = require('tamejs').runtime;

var __tame_defer_cb = null;
(function(){})(tame.end);

@maxtaco maxtaco merged commit cded996 into maxtaco:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 3, 2012
  1. @sktaylor

    fix output on blank file input, previously produced invalid javascrip…

    sktaylor authored
    …t, now it produces a valid file
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/ast.js
View
7 lib/ast.js
@@ -1995,7 +1995,12 @@ function Program (shbang, statements) {
out.addLine ("var __tame_defer_cb = null;");
var body = this._body.compile (eng);
out.addOutput (body);
- out.addLine (body.fnName() + " (" + out.endFn() + ");");
+ if(body.fnName() === undefined){
+ out.addLine ("(function(){})(" + out.endFn() + ");");
+ }else{
+ out.addLine (body.fnName() + " (" + out.endFn() + ");");
+ }
+
return out;
};
Something went wrong with that request. Please try again.