Skip to content

nil cannot be used as an argument to a memoized function if any non-nil arguments follow it #10

@djsigmann

Description

@djsigmann
local memoize = require 'memoize'

local function f(...) return end
local F = memoize(f)

-- nil cannot be used as an argument if any non-nil arguments follow it
F(true, nil) -- runs, but cache is not correctly stored to or accessed
F(nil, nil)  -- runs, but cache is not correctly stored to or accessed
F(nil, true) -- throws an error: table index is nil

To avoid this from happening, some extra logic would have to be run when a function parameter is nil.

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