Skip to content

Conversation

ammarahm-ed
Copy link
Contributor

Closes #858

@ammarahm-ed
Copy link
Contributor Author

ammarahm-ed commented Jan 29, 2025

It seems that this works on mac but fails on Linux and Windows.

@saghul
Copy link
Contributor

saghul commented Jan 29, 2025

Yes it seems like you'll have to go back to explicitly testing for infinity.

@ammarahm-ed
Copy link
Contributor Author

@saghul can you start the tests again

@ammarahm-ed
Copy link
Contributor Author

Hey @saghul I didn't look closely at your diff in review, fixed now and all tests now pass.

@saghul
Copy link
Contributor

saghul commented Jan 31, 2025

On a second thought, if we want to 100% mimic how v8 behaves we should store the JSValue and extract it when necessary.

Right now if you set it to -Infinity you'll get back 0, whereas Chrome gets you back the same value you set.

Thoughts @bnoordhuis ?

@bnoordhuis
Copy link
Contributor

That means calling JS_ToFloat64, which can throw an exception, when we're already in an exception state. What is the expected behavior of this?

Error.stackTraceLimit = {valueOf(){ throw "evil" }} try{ throw new Error("fail") } catch(e){ console.log(e) } // "fail" or "evil"?
@saghul
Copy link
Contributor

saghul commented Jan 31, 2025

I Node one gets "fail". We do save the previous exception not to clobber it, so it seems like we should be good to do that?

@bnoordhuis
Copy link
Contributor

Yeah, that seems reasonable. Let's follow what node/chrome do then.

FWIW, I'm okay with landing this PR as-is and then one of us doing a follow-up fix-up.

@saghul saghul merged commit eab8251 into quickjs-ng:master Jan 31, 2025
61 checks passed
@saghul
Copy link
Contributor

saghul commented Jan 31, 2025

Sounds good! I can work on it.

@ammarahm-ed ammarahm-ed deleted the fix-stacktracelimit branch February 8, 2025 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants