-
Notifications
You must be signed in to change notification settings - Fork 465
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
Promise returned undefined instead of value (10.0.1 & 10.1.1) #5958
Comments
Would you be able to give a self-contained example (can be compiled without any additional code), with only the minimal code strictly needed to observe the difference. (E.g. |
Sure! I'll try to that over the weekend |
I'm also experiencing something similar (ReScript 10.1.2). Example code: Js.Promise2.resolve("hello")
->Js.Promise2.then(v => {
Js.log(v)
Js.Promise2.resolve("hello 2")
})
->Js.Promise2.then(v => {
Js.log(v)
Js.Promise2.resolve("hello 3")
})
->ignore When run it prints
And I expect it to print:
Compiled code: var Js_promise2 = require("rescript/lib/js/js_promise2.js");
Js_promise2.then(Js_promise2.then(Promise.resolve("hello"), (function (v) {
console.log(v);
return Promise.resolve("hello 2");
})), (function (v) {
console.log(v);
return Promise.resolve("hello 3");
})); If I try to log the result of calling the console.log(Js_promise2.then(Promise.resolve("hello"), (function (v) {
return Promise.resolve("hello 2");
}))) I get I also get |
Silly mistake. Fix in #5996 will be in the next 10.3 bug fix release. |
Thank you for filing! Check list:
===========================================
Hi!
I've noticed, in some conditions, some promises returning "undefined" instead of the value they should return.
I got it working by using a different syntax, but I thought you might be interested.
I've got the following code
Which compiles to
In another module, I use it like this:
Interestingly,
Js.log2("outputs", outputs)
inAdapter.res
prints the expected values.But
Js.log2("Results: ", results)
prints undefined (and the rest of the logic falls apart afterwards accordingly).And it was the case using both 10.0.1 (with
@ryyppy/rescript-promise
) and 10.1.1 (withJs.Promise2
)However, when updating the
otherAction
inAdapter.res
to use async / await syntax, like below, it all works as expected, and both Js.log2 output the expected values.which compiles to
The text was updated successfully, but these errors were encountered: