Skip to content

runEffectFn10 drops its tenth argument (j) #1

@Unisay

Description

@Unisay

Summary

runEffectFn10 in src/Effect/Uncurried.lua drops its tenth argument: it binds ten curried parameters a through j but only forwards nine of them to the underlying uncurried function, calling fn(a, b, c, d, e, f, g, h, i) instead of fn(a, b, c, d, e, f, g, h, i, j).

Offending code

runEffectFn10 = (function(fn)
  return function(a)
    return function(b)
      ...
        return function(j)
          return function()
            return fn(a, b, c, d, e, f, g, h, i)   -- j is silently dropped
          end
        end
      ...

Root cause

A copy/paste arity error when the curried-application body was written. Every other member of the family is correct: runEffectFn1 through runEffectFn9 each forward exactly their N arguments, and all of mkEffectFn1 through mkEffectFn10 forward the full curried chain. Only runEffectFn10's final call is short by one argument.

Impact

Any PureScript code that imports a foreign function via EffectFn10 and invokes it through runEffectFn10 will execute the underlying function with its tenth argument bound to nil. The call still type-checks on the PureScript side and produces no runtime error, so the failure is silent: the tenth parameter is simply lost. In Lua this is especially easy to miss because a missing trailing argument is not an error, it just becomes nil.

How it was found

Running luacheck --quiet --std min src/ flags the dropped binding as a dead parameter:

src/Effect/Uncurried.lua:197:39: unused argument j

The j parameter is declared but never read precisely because the call site omits it.

Audit of the rest of the family

I audited the whole mkEffectFnN / runEffectFnN family in this file. runEffectFn10 is the only offender. There are no Data.Function.Uncurried-style helpers (mkFnN / runFnN) in this repository.

Fix

Forward j in the final call:

return fn(a, b, c, d, e, f, g, h, i, j)

This is a one-token change confined to src/. After it, luacheck no longer reports the unused-argument warning for src/Effect/Uncurried.lua.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions