Skip to content

Reject extra arguments to .new(), etc. #93

@jwdevel

Description

@jwdevel

If I have a type bound to Lua, I can construct like so:

v = vec4.new(1,2,3,4)

However, .new will also take any extra arguments and ignore them:

v = vec4.new(1,2,3,4,'foo', 'bar?')
-- v is a valid vec4, no error

Maybe these cases should be rejected?

This can lead to confusion if we hav, eg. vec2, vec3, vec4, like so:

-- It looks like we meant to create vec4
-- If we don't notice the '2' character, it is confusing.
v = vec2.new(10,20,30,40)

I don't know kaguya's internals, but couldn't the constructor (or other functions) check lua_gettop when they're called?

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