Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwdevel opened this issue May 22, 2020 · 0 comments
Open

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

jwdevel opened this issue May 22, 2020 · 0 comments

Comments

@jwdevel
Copy link

jwdevel commented May 22, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant