alongubkin / alongubkin/spider

Spider sample code not executing properly

Ouverte
#130 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
JavaScript
Étoiles
1.3k
Forks
46
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.:30:81
at Object.ModuleStore.getAnonymousModule (/usr/local/lib/node_modules/spider-script/node_modules/traceur/bin/traceur.js:953:30)
at evalmachine.: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?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.