Comments (3)
Thanks for this. I'm always excited to learn about JS-Interpreter bugs.
Here's a minimal testcase:
function myFunc() {
myFunc = 42;
}
myFunc();
alert(myFunc);
Browser output: 42
JS-Interpreter output: [object Function]
This will be fixed immediately. Investigating...
from js-interpreter.
There are two bugs here:
- With function declarations, per example given in the previous comment.
- With named function expressions:
should return the function object in nonstrict mode, and throw
alert((function foo() { foo = 42; return foo; })())
TypeError: Assignment to constant variable
in strict mode, but in fact returns42
.- The name of a named function expression is an immutable binding within the body of the function.)
- N.B. however that it can be shadowed by a parameter or variable:
and
alert((function foo(foo) { foo = 42; return foo;})())
should both return 42 in either strict or nonstrict mode.alert((function foo() { var foo = 42; return foo;})())
from js-interpreter.
Tested the fix, it works perfectly. Thank you very much!
JS-Interpreter and Blockly are two great projects, your efforts are much appreciated.
If there is a way to send you both a beer or two, please let me know :)
from js-interpreter.
Related Issues (20)
- `REGEXP_MODE=2` causes leak and eventual crash in Chrome
- Highlight/Select the line of code while executing HOT 3
- 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
- Can we use destructuring? HOT 2
- Try catch syntax does not work correctly when using native syntax HOT 2
- Bug report about error message HOT 9
- 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
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.