Skip to content

Detailed argument errors #31

Open
Open
@SquidDev

Description

@SquidDev

Compare Cobalt:

> string.sub(false)
stdin:1: bad argument: number expected, got boolean

with PUC Lua:

> string.sub(false)
stdin:1: bad argument #1 to 'sub' (string expected, got boolean)

The latter is obviously much more descriptive and useful. There's two things we should be doing here:

  • Keeping argument indexes in the error message.
  • Include error messages. See luaL_argerror for how it's done by Lua, but it's not entirely clear this is correct in the presence of tailcalls - we may need some additional sanity checks.

Also worth thinking about how, if at all, we can expose this to CC.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions