Skip to content

Docs: Fix type error in getting started guide

The CameLIGO getting started guide has some type inconsistencies in the Quickstart section

It starts out with defining the return type

type storage = int
type return_type = operation list * storage

Then when defining the add and sub entrypoints, it then uses result instead of return_type

add

[@entry] let add (n : int) (storage : storage) : result = [], storage + n

sub

[@entry] let sub (n : int) (storage : storage) : result = [], storage - n

Trying to follow the tutorial as is then leads to a type error when trying out the contract

| ❯ ligo run dry-run counter.mligo 'Add(3)' '5'                                   |
|---------------------------------------------------------------------------------|
| File "counter.mligo", line 5, characters 49-55:                                 |
|   4 |                                                                           |
|   5 | [@entry] let add (n : int) (storage : storage) : result = [], storage + n |
|   6 |                                                                           |
|                                                                                 |
| Type "result" not found.                                                        |

Replacing result with return_type should fix it.

It would be nice to fix the return type for the add and sub functions to avoid confusion for new users most likely trying out the project for the first time. It would be a better experience not to face errors on the first try

Affected versions:

Edited by Kevin Gathuku