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

Can't use a JsArray, set method doesn't match with docs. #218

Closed
pietrovismara opened this issue Aug 5, 2017 · 2 comments
Closed

Can't use a JsArray, set method doesn't match with docs. #218

pietrovismara opened this issue Aug 5, 2017 · 2 comments

Comments

@pietrovismara
Copy link

Hi, i'm trying to learn how to use the amazing neon, but i can't really understand a thing.

If i try to execute this code:

let js_arr: Handle<JsArray> = try!(try!(call.arguments.require(scope, 1)).check::<JsArray>());
js_arr.set(0, JsNumber::new(scope, 1000));

I get this error on the second line (js_arr.set): This function takes 3 parameters but 2 were supplied.
I don't understand why since it's a JsArray. Even Racer tells me that the set method takes 2 parameters. But no matter what, js_arr.set takes 3 parameters in this order: &mut bool, neon::macro_internal::runtime::raw::Local and neon::macro_internal::runtime::raw::Local.

Can someone please explain me what's happening? I'm getting crazy trying to understand how JsArray works.

@shepmaster
Copy link

Likely duplicate of #57.

@pietrovismara
Copy link
Author

Issue solved, but i would like to notice that i already imported Object.
These were my original imports:

use neon::vm::{Call, JsResult};
use neon::mem::Handle;
use neon::js::{JsInteger, JsNumber, JsString, JsObject, JsArray, JsValue, Object, Key};
use neon::js::error::{JsError, Kind};

Somehow changing them to the following fixed the issue:

use neon::vm::{Call, JsResult};
use neon::mem::Handle;
use neon::js::{Object, JsArray, JsInteger, JsObject, JsNumber};

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

2 participants