Operator == not compatible with types string storage ref and string storage ref

jagers757jagers757 Member Posts: 1
edited September 2015 in Solidity
Using the online solidity compiler, I get this message which does not make sense:

:41:16: Type error: Operator == not compatible with types string storage ref and string storage ref
if(books[i].title == tmp.title){
^-------------------------^
Is this a bug or is there something I am missing? How should I be comparing the string that was passed in to the string that is in storage?
Here is the contract code:

contract Library is mortal {

struct Book{
string title;
string author;
string desc;
string image;
}

Book[] public books;
Book private tmp;
uint constant reserved = 1000000000000;

function create(string _title, string _author, string _desc, string _image) returns (uint) {
if(exists(_title,_author))
return reserved;

uint index = books.length;
books[index].title = _title;
books[index].author = _author;
books[index].desc = _desc;
books[index].image = _image;
return index;
}

function exists(string _title, string _author) returns (bool) {
tmp.title = _title;
tmp.author = _author;
for(uint i; i < books.length; i++){
if(books[i].title == tmp.title){
if(books[i].author == tmp.author)
return i;
else
return false;
}
}
return false;
}

function setDescription(uint _index, string _desc) returns (bool) {
if(books[_index]){
books[_index].desc = _desc;
return true;
}
return false;
}
}

Comments

Sign In or Register to comment.