Giter Club home page Giter Club logo

Comments (3)

NeilFraser avatar NeilFraser commented on July 28, 2024

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.

cpcallen avatar cpcallen commented on July 28, 2024

There are two bugs here:

  1. With function declarations, per example given in the previous comment.
  2. With named function expressions:
    alert((function foo() { foo = 42; return foo; })())
    should return the function object in nonstrict mode, and throw TypeError: Assignment to constant variable in strict mode, but in fact returns 42.
    • 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:
      alert((function foo(foo) { foo = 42; return foo;})())
      
      and
      alert((function foo() { var foo = 42; return foo;})())
      
      should both return 42 in either strict or nonstrict mode.

from js-interpreter.

malwarebin avatar malwarebin commented on July 28, 2024

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)

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.