I'm getting the following error:

Data location must be "calldata" for parameter in external function, but "memory" was given.

for the following function:

    function _registerAirline(address addr, string memory name)
        require(!airlines[addr].isRegistered, "Airline is already registered");

        airlines[addr] = Airline({
            name: name,
            isFunded: false,
            isRegistered: true

        emit AirlineRegistered(

But, when I change the string memory name to string calldata name and compile, I get an error:

ParserError: Expected ',' but got identifier
function _registerAirline(address addr, bytes calldata name)
  • 1
    What version of solidity are you using? At least 0.6.7 and 0.5.17 work as expected and they do not generate that error message. – Ismael May 23 at 1:59
  • 1
    full code of contract will give more idea on error because changing memory to calldata work for me fine without error. – Mahesh Rajput May 23 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.