You have an uninitialized storage pointer because you are declaring a storage array inside your function.
You should never do that because it will overwrite storage in unexpected ways. The issue of not returning is resolved by declaring it properly:
pragma solidity ^0.4.24;
contract test {
uint[] values = [1,2,3,4,5,6];
uint[] auxArray;
function removeValueFromArray(uint _num) public returns(uint[]) {
//uint[] storage auxArray;
for (uint i = 0; i < values.length; i++){
if(values[i] != _num)
auxArray.push(values[i]);
}
return auxArray;
}
}
Background on storage pointers: https://blog.b9lab.com/storage-pointers-in-solidity-7dcfaa536089
I imagine this is experimental. In Solidity, this is a bad approach to a delete/splice operation generally, because it relies on a for loop and a lot of moving data around. https://blog.b9lab.com/getting-loopy-with-solidity-1d51794622ad
Have a look over here from some patterns, including one that does delete. Are there well-solved and simple storage patterns for Solidity?
Keep in mind that in practice, delete isn't used very often and truthfully, nothing on blockchains is every really deleted, although we can treat elements that way logically.
I mention this because the delete setup adds complexity you might not need.
Hope it helps.
mapping(uint => uint)could be a lot more suitable. You map each value to the number of times that it appears, and when you want to remove that value, then simply change its count to 0. – goodvibration Feb 14 '19 at 10:51