-
Notifications
You must be signed in to change notification settings - Fork 9
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
Valid value types - resolving promise with nil #3
Comments
I'll just leave an observation:
and
can be distinguished using
I do not know what changes you would have to make to the code to implement this, but distinguishing them is certainly possible. |
@Luca-spopo nice trick! Although I still believe that this distinction is not needed in promise.lua and resolving with nil is absolutely fine and doesn't cause any strange side effects. Maybe someone will prove me wrong on this in the future but for now I accept my own thesis as a fact 😄 |
@4O4 I agree with you. |
@jojo59516 it's true that lua tables can't store nil, but the functions can return them.
are all distinct in lua and, depending on who's coding, the difference can matter I agree with 404 that changes need to be made, but it's because the doc is wrong in asserting that the functions cannot be distinguished |
@Luca-spopo Yes, I know they are actually different.
So, storing a (Forgive my bad English :) |
When a JS function returns nothing, it's return value is So I believe the spec intends the following:
To that end, I too believe the |
Sadly, this project seems to be abandoned |
README states, that:
Can you provide a further explanation why promises cannot be resolved with
nil
in this implementation? Because I believe that the fact that lua does not distinguish between those two return variants doesn't make any difference here and doesn't justify this behaviour.In javascript,
return;
orreturn undefined;
or no return statement at all, have the same effect (function result isundefined
) and it is allowed to resolve a promise without value / with undefined.It's pretty annoying that promise.lua doesn't allow this and you are forced to explicitly provide dummy value just to make the
resolve()
work. It seems thatnil
is banned in https://github.com/Billiam/promise.lua/blob/master/promise.lua#L53 and removing this condition wouldn't break anything. But... It's possible that I'm simply wrong here, so I would really like to get more information about this.The text was updated successfully, but these errors were encountered: