Closed SkibidiProduction closed 4 months ago
After testing with valgrind, I identified that the error occurred when calling the destructor. It appears that PHP calls the destructor before dealing with __construct
method exceptions. The destructor was trying to free an NDArray that did not exist.
The constructor is already supporting an empty array now, but I found that the __toString
method and print_r
are not able to handle empty arrays. I will correct this in another MR.
Empty array initialization fixed in https://github.com/NumPower/numpower/pull/60
When running the following code:
I expect to receive:
Instead I get a segmentation fault:
The same problem occurs if I try to pass an empty array or invalid value:
If we talk about the problem of passing an empty array, then in #54 and #56 I processed this case and threw an exception. However, now I think that perhaps this is not quite the right approach and we should give the user the opportunity to create instances of the class from an empty array.