Closed ZyX-I closed 7 years ago
LuaJIT succeeds and gets SEGV at exit.
is_same
is more analogous to ==
in C/C++. There really is no analog to memcmp
in lua, besides you wouldn't really use memcmp
to compare two C++ objects for equality (i.e. memcmp
does not perform a deep compare). You would have the same problem if you were to attempt the same comparison in C/C++ or any programming language, it would also perform a floating-point compare for NaN values nested inside a container.
In your case it may be better to create a special table that represents NaN instead. Replacing numeric NaN with table NaN where appropriate or wrapping your function that may return NaN to return table NaN.
@o-lim In C ==
does not perform deep comparison either like it does here. Not sure about C++, but I guess it will not without overriding ==
. Also note that e.g. authors of numpy
know that tests that compare NaN equal are needed: numpy.testing.assert_array_equal (numpy.testing.assert_equal also has this property, but it is not expressed in documentation).
As the alternative it makes sense to either have different is_same
version or an optional argument to is_same
that makes it compare NaN values equal.
In any case first it is needed to report luajit crash. I do not yet have minimal working example, but can say that:
--filter=NaN
does not make luajit crash. Including running only table test that is required to crash the test suite.Any updates here?
Fixes Olivine-Labs/busted#453.