0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

solidity TypeError: Integer constant expected の解決

Posted at
  Todo[] public todos;

  ...

  function updateTODO(uint _id, bool _state) public onlyMine(_id) {
    // 指定の id の TODO をアップデートする
    // アップデートは完了・非完了のみ
    Todo[_id].state = _state;
  }
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/todo.sol

TypeError: Integer constant expected.
  --> project:/contracts/todo.sol:63:10:
   |
63 |     Todo[_id].state = _state;
   |          ^^^

compile err になるなぜ。

  function updateTODO(uint _id, bool _state) public onlyMine(_id) {
    // 指定の id の TODO をアップデートする
    // アップデートは完了・非完了のみ
-   Todo[_id].state = _state;
+   todos[_id].state = _state;
  }

こうだった。todos が変数じゃん・・・凡ミス
というかエラーメッセージがひどすぎる・・・。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?