Giter Site home page Giter Site logo

Comments (9)

NeilFraser avatar NeilFraser commented on June 30, 2024

When run on https://neil.fraser.name/software/JS-Interpreter/ in both uncompressed and compressed modes, I get changed!. Can't recreate. Can you double-check?

from js-interpreter.

ayahito-saji avatar ayahito-saji commented on June 30, 2024

Could you please open the developer's console?
You should see Uncaught TypeError: default.

from js-interpreter.

NeilFraser avatar NeilFraser commented on June 30, 2024

Whoa, it works fine (changed!) on Firefox, it fails (default) in Chrome. Was not expecting that!

from js-interpreter.

ayahito-saji avatar ayahito-saji commented on June 30, 2024

Wow, that is strange behavior.
I tested it with Chrome and Node.js and it failed.
The syntax for assigning stack traces was non-standard.
It may be that different browsers behave differently.

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Error/stack

from js-interpreter.

ayahito-saji avatar ayahito-saji commented on June 30, 2024

Perhaps the code that generates the stack trace from the error message is in the wrong place.
The stack trace should be generated at the time of the throw, not at the time the error is generated, right?
https://github.com/NeilFraser/JS-Interpreter/blob/master/interpreter.js#L2290C3-L2305C45

from js-interpreter.

NeilFraser avatar NeilFraser commented on June 30, 2024

This is getting weirder and weirder. Take this screenshot from Chrome's console:
Screenshot 2024-02-28 at 19 45 41
Here the exact same commands are entered twice. The difference is that the lines above are copied and pasted into the console, whereas the lines at the bottom were manually typed. And the results are different.

from js-interpreter.

NeilFraser avatar NeilFraser commented on June 30, 2024

Filed a bug with Chrome console: https://issues.chromium.org/issues/327467399

Let's put this issue on ice until we can get Chrome to be consistent (one way or the other). Firefox behaves as expected.

@cpcallen : Chris you might find this entertaining.

from js-interpreter.

cpcallen avatar cpcallen commented on June 30, 2024

This is indeed entertaining.

Perhaps the code that generates the stack trace from the error message is in the wrong place. The stack trace should be generated at the time of the throw, not at the time the error is generated, right?

Although the ECMAScript spec has never mentioned anything about the .stack property on Error objects, as far as I am aware all JS runtimes set this at the time the Error object is created, not when it is thrown.

The reason for this is that otherwise it would break this very useful pattern:

try {
  mightThrow();
} catch (e) {
  if (e instanceof RecoverableError) {
    recoverFrom(e);
  } else {
    throw e;  // Rethrow unrecoverable error.
  }
}

So the code in JS Interpreter looks correct to me, but there does seem to be something funky going on with Chrome.

from js-interpreter.

ayahito-saji avatar ayahito-saji commented on June 30, 2024

The behavior of Chrome is very weird.
Thank you for reporting the bug.

And thank you for the clear explanation of when the error is generated.

from js-interpreter.

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.