Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange problem when using default parameters #309

Closed
mstoykov opened this issue Jul 22, 2021 · 0 comments
Closed

Strange problem when using default parameters #309

mstoykov opened this issue Jul 22, 2021 · 0 comments

Comments

@mstoykov
Copy link
Contributor

The following code (the original is the current harness/compareArray.js in tc39 which is a lot longer):

function A() {};
A.B = function () {};
function D(message = '') {
  var C = A.B;
  C([1,2,3]); // throws "Value is not an object: undefined"
};

D()

Throws "Value is not an object: undefined" at the line C is called (as commented). This does not happen if

  1. A.B is used directly
  2. message = '' is just message - remove the default value
@dop251 dop251 closed this as completed in e981f83 Jul 22, 2021
Gabri3l added a commit to mongodb-forks/goja that referenced this issue Jan 31, 2022
* Avoid calling iterator's return method again when it throws
* Fixed dynamic variable resolution when a parent lexical binding exists
* Support dereferencing in ExportTo(). Closes dop251#300
* Removed the mention of the es6 branch, updated the section about new features development.
* Destructuring assignments, rest and spread properties, default function parameters (dop251#303)
* Fixed argument variable reference resolution in stashless functions
* Fixed binding order for global function declarations when there are duplicate names. Fixes dop251#344.
* Make sure variables dynamically bound in parameter scope conflict with parameter bindings. See dop251#305.
* Fixed setting the stack pointer in enterFuncBody. Fixes dop251#309
* Support for assignment patterns in for-in and for-of loops. Support for spread elements in call arguments. Fixed various issues related to destructuring assignments. See dop251#305.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant