Skip to content

Valid value types - resolving promise with nil #3

@4O4

Description

@4O4

README states, that:

  • Promises cannot be resolved with null (nil). Lua does not distinguish between

    function()
        return nil
    end

    and

    function()
        return
    end
  • Lua does not have an undefined type.

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; or return undefined; or no return statement at all, have the same effect (function result is undefined) 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 that nil 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions