Skip to content

Spider sample code not executing properly #130

@Zacqary

Description

@Zacqary

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions