[Ethereum] TypeError: Data location must be “memory” for parameter in function, but none was given

remixsoliditytruffletruffle-contracttruffle-migration

Contract fail to compile in IDE Remix.due to the following error:

TypeError: Data location must be "storage" or "memory" for parameter
in function, but none was given.

version:0.5.6+commit.b259423e

I have no idea why this happened and i have not found any sufficient information on how i can fix it and was hoping you can help me. Thank you in Advance.

The error points to this function:

function bytesToAddress(bytes bys) pure private returns(address addr) {
        assembly {
            addr := mload(add(bys, 20))
        }

Best Answer

It needs to be

function bytesToAddress(bytes memory bys) ...

Hope it helps.