-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
cannot access 'i' before initialization #2760
Comments
Huh, I tried to reproduce it in the |
I've reproduced it with multiple versions, let me double check. |
I can confirm that the issue presents on the latest commit hash on main. Here's the commit hash: cf85843 Here's the [package]
name = "boa_uint8array"
version = "0.0.0"
edition = "2018"
[dependencies]
boa_engine = { git = "https://github.com/boa-dev/boa", rev = "cf85843dc838c7c36e6b635b34f31d100e64c63b" } |
Did you ensure to paste this exact minified code in? https://github.com/indutny/elliptic/blob/master/dist/elliptic.min.js |
Here's the Rust without that minified code pasted in without modification: fn main() {
let mut context = boa_engine::Context::default();
let exports_js_value = context
.eval_script(boa_engine::Source::from_bytes(r#""#))
.unwrap();
println!("{:#?}", exports_js_value);
} |
Finally could reproduce the issue, I was accidentally running the unminified script instead of the minified one 😅 The upside is that elliptic.js does work without problems, it's just the minified version the one that is giving the engine some trouble. I'll put this in the pre-v1 tracker, and I'll probably debug it next week. |
I think the issue still presents when you try to use the library using the non-minified version, unfortunately. |
Yeah, and it seems to be the same issue. I tried to create an encryption context using the let script = include_bytes!("test.js");
let context = &mut Context::default();
match context.eval_script(Source::from_bytes(script)) {
Ok(v) => println!("{}", v.display()),
Err(e) => eprintln!("{}", e),
}
let elliptic = context
.global_object()
.clone()
.get("elliptic", context)
.unwrap()
.as_object()
.unwrap()
.clone();
let constructor = elliptic
.get("ec", context)
.unwrap()
.as_object()
.unwrap()
.clone();
match constructor.construct(&["curve25519".into()], None, context) {
Ok(v) => println!(
"{}",
JsValue::new(v)
.to_string(context)
.unwrap()
.to_std_string_escaped()
),
Err(e) => eprintln!("{}", e),
} and it returned:
Seems to be the same problem of |
Describe the bug
I am trying to use an npm package called elliptic. This is a popular library, and with that knowledge it is a safe assumption that it works well in the common JS engines. I have tested it locally in Node.js and it works fine.
Unfortunately when trying to import the most basic functionality in Boa, this error is thrown:
I have looked through the source code, and the variable referenced in the error is always declared with
var
and neverconst
orlet
, so I don't think this error should be thrown.To Reproduce
Just throw this code into a Boa script and execute it: https://github.com/indutny/elliptic/blob/master/dist/elliptic.min.js
The error will be thrown.
Expected behavior
This error should not be thrown, and the code should work just fine.
Build environment (please complete the following information):
I don't believe this information is relevant.
Additional context
I believe this issue has a high likelihood of being related: #1393
The text was updated successfully, but these errors were encountered: