sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

No error on argument type mismatch for optional with SOL_SAFE_NUMERICS

Open glebm opened this issue 7 months ago • 0 comments

I have a function like this:

void f(std::optional<uint8_t> x);

The intent is that it can be called from Lua with or without an argument.

So this works:

-- passes nullopt
f()

-- passes 1
f(1)

However, the following also works and passes nullopt!

-- passes nullopt!
f('string')

This seems like a bug. I'd prefer it to raise a Lua error instead!

My sol2 config:

#define SOL_SAFE_USERTYPE 1
#define SOL_SAFE_REFERENCES 1
#define SOL_SAFE_FUNCTION_CALLS 1
#define SOL_SAFE_FUNCTION 1
#define SOL_SAFE_NUMERICS 1
#define SOL_IN_DEBUG_DETECTED 0

glebm avatar Nov 11 '23 12:11 glebm