Comments (9)
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.
Could you please open the developer's console?
You should see Uncaught TypeError: default
.
from js-interpreter.
Whoa, it works fine (changed!
) on Firefox, it fails (default
) in Chrome. Was not expecting that!
from js-interpreter.
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.
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.
This is getting weirder and weirder. Take this screenshot from Chrome's console:
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.
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.
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 throw
n.
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.
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)
- Add: Support for cloudflare workers HOT 4
- import momentjs library HOT 3
- This repo is being mocked in r/ProgrammerHumor. HOT 1
- detect when the interpreter is waiting for an async function callback HOT 4
- JS-Interpreter errors and script errors distinction HOT 4
- Replace string with regexp return undefined HOT 2
- [QUESTION] How to throw exception from createAsyncFunction ? HOT 1
- Include in REACT typescript ? HOT 4
- How to get the function in the return value HOT 2
- Viability as an Expression/Predicate Interpreter? HOT 1
- A named function, existing as a variable in its own local scope, shadows the global declaration HOT 3
- Can we use destructuring? HOT 2
- Try catch syntax does not work correctly when using native syntax HOT 2
- Do you plan to support function replacer in JSON.stringify? HOT 3
- Make js-interpreter ready for node and NPM HOT 3
- IPC between sandbox and parent process (Node.js) HOT 2
- Tasks created through createTask_ (such as when using setTimeout) are incorrectly interpreted as throwing their return values. HOT 2
- how to pass multiple parameters and/or arrays/objects to functions? HOT 2
- Notion of preload HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-interpreter.