Compile Error

I cannot understand why this happens.I copied and pasted this code from https://zoom-blc.com/how-to-create-first-dapp

Error message is as follows:

truffle(develop)> compile
Error parsing /Users/akitasatoshi/pet-shop-tutorial/contracts/Adoption.sol: ParsedContract.sol:10:3: ParserError: Expected primary expression.
    return petId;

The code is as follows:

pragma solidity ^0.4.23;

contract Adoption {

  address[16] public adopters;

  function adopt(uint petId) returns(uint) { 
    require(petId >= 0 && petId =< 15);
    adopters [pedId] = msg.sender;
    return petId;

  function getAdopters(uint) public returns (address[16]) {
    return adopters;

2 Answers 2


A few things:

  • There's no closing brace on your contract.
  • There's a space in the line adopters [pedId].
  • There's a typo in the same line. pedId -> petId.

The actual issue you've reported is due to =<, which should be <=.


I copied and pasted this code from...

Okay, I tried copy+pasting from that site, and Remix didn't like it. There seem to be some special characters at the beginning of each line that are causing problems, specifically U+3000, which is the "Ideographic Space" character. Might be related to it being a Japanese site? Don't know.

Removing any whitespace from the beginning of each line, then re-indenting using a "normal" space/tab gets things working.

  • Firstly, sorry for lots of typos.. Thank you! I could compile them. I did not notice the "Ideographic Space", so wondered error which indicating blank.
    – Ryo Akita
    Commented Oct 10, 2018 at 21:56

I experienced a similar error when defining an event. The problem was that I was defining it inside of a function, when it should have been at the contract level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.