Giter VIP home page Giter VIP logo

Comments (4)

LeifAndersen avatar LeifAndersen commented on September 14, 2024

I should mention that the program does run properly on the stopify home page. So it might be that I'm running it incorrectly?

from stopify.

arjunguha avatar arjunguha commented on September 14, 2024

It is definitely a Stopify bug, which should behave correctly regardless of runtime/compiler options.

An equivalent program works correctly on Ocelot:

https://code.ocelot-ide.org/?gist=arjunguha/aefe0f874a10db181eaa610a7c740fad

However, Ocelot does a bunch of other transformations that may be masking the problem.

Looks like the default estimator in Stopify is "velocity", and that the version that you're using is the same version that ElementaryJS uses:

https://github.com/ocelot-ide/Stopify/blob/3ac8225e495bed2a783a696addb4852a69970e30/stopify/src/runtime/check-runtime-opts.ts#L36

from stopify.

arjunguha avatar arjunguha commented on September 14, 2024

Here is a variation of an example that Leif sent over email, which shows the same problem:

<script src="https://github.com/ocelot-ide/Stopify/releases/download/0.7.3/stopify-full.bundle.js"></script>
<script>
const prog = `
var i = 0;
debugger;
while(i < 10) {
    console.log(i);
    var G = i + 1;
    i = G;
};`;
let runner = stopify.stopifyLocally(prog);
runner.g = {console};
runner.run(() => {
    console.log(runner.g.G, runner.g.i);
    console.log("DONE!");
});
</script>

If you pretty-print the code around the debugger, you see that the loop body translates to:

if ($__R.mode) {
  G = $S.g.i + 1; // BUG HERE: the l-value should be $S.g.G, I believe
  $S.g.i = $S.g.G
}

The bug is almost certainly in this file, which introduces the global object:

https://github.com/ocelot-ide/Stopify/blob/master/hygiene/ts/useGlobalObject.ts

I believe the problem is masked in Ocelot, because it wraps the entire program in a thunk (IIRC, though I forget why).

from stopify.

arjunguha avatar arjunguha commented on September 14, 2024

My guess is that loop bodies are considered "scopes" in Babel (which they are for let- and const- bound variables). So, the condition here is probably wrong:

https://github.com/ocelot-ide/Stopify/blob/master/hygiene/ts/useGlobalObject.ts#L91

from stopify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.