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

Spider sample code not executing properly #130

Open
Zacqary opened this issue Mar 14, 2015 · 1 comment
Open

Spider sample code not executing properly #130

Zacqary opened this issue Mar 14, 2015 · 1 comment

Comments

@Zacqary
Copy link

Zacqary commented Mar 14, 2015

I tried to run the sample code on spiderlang.org (with a modification so it didn't depend on a global function that wasn't there)

fn TimeMachine(pilot) {
  this.pilot = pilot;

  this.go = fn (noise) {
    ::console.log(noise);
  };
}

fn Tardis()
  extends TimeMachine("The Doctor") {

  this.go = () =>
    super.go("vorp vorp");
}

fn DeLorean()
  extends TimeMachine("Marty") {

  this.go = () =>
    super.go("One point twenty-one gigawatts!");
}

fn getTimeMachines(){
    return [new Tardis(), new DeLorean()];
}

for timeMachine in getTimeMachines() {
  timeMachine?.go();
}

But this throws an error:

/usr/local/lib/node_modules/spider-script/cli.js:92
        vm.runInNewContext(compilerOutput.result, sandbox);
           ^
TypeError: Property '__$503654756$5$__' of object object is not a function
    at evalmachine.<anonymous>:30:81
    at Object.ModuleStore.getAnonymousModule (/usr/local/lib/node_modules/spider-script/node_modules/traceur/bin/traceur.js:953:30)
    at evalmachine.<anonymous>:1:29
    at /usr/local/lib/node_modules/spider-script/cli.js:92:12
    at fs.js:272:14
    at Object.oncomplete (fs.js:108:15)

Whereas this code runs fine:

getTimeMachines()[0].go();
getTimeMachines()[1].go();

So it looks like something's going on with the way for in loops are being compiled.

Is this a bug in Spider or did I get the install instructions wrong?

@Zacqary
Copy link
Author

Zacqary commented Mar 15, 2015

Tried compiling to ES6, then running with Babel, and it works. Looks like something's up with Traceur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant