-1

I am using the Remix IDE and the followinf code is throwing the error:

:browser/tests/project/record.sol:18:21: ParserError: Expected ';' but got '[' address docs[] = new ;

pragma experimental ABIEncoderV2;
pragma solidity >=0.4.18;

contract Record {

    struct MedRecord {
        string password;
        string name;
        address patient;
        address[] doctor;
    }
    mapping(address => MedRecord) internal medRecords;

    address[] public recordList;


    function addRecord(address _key, string memory password, string memory name) public {
        address docs[] = new ;
        medRecords[_key] = MedRecord(password, name, _key, []);
        recordList.push(_key);
    }

    function remove(address _key) public {
        delete medRecords[_key];
    }
    
    // function contains(address _key) public view returns (bool) {
    //     return MedRecords[_key][0] != '';
    // }
    
    function getByKey(address _key) public view returns (MedRecord memory) {
        return medRecords[_key];
    }
}

However, the code looks fine to me.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83

1 Answers1

0

This statement is not complete :

address docs[] = new ;

You should write something like this instead :

address[] memory docs = new address[](2);
Emmanuel Collin
  • 2,556
  • 2
  • 10
  • 17
  • medRecords[_key] = MedRecord(password, name, _key, []) Now in this line its showing error.TypeError: Unable to deduce common type for array elements. medRecords[_key] = MedRecord(password, name, _key, []); – Shobhit Nov 09 '20 at 08:02