Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
L
LIGO
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 151
    • Issues 151
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Jira
    • Jira
  • Merge Requests 44
    • Merge Requests 44
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ligolang
  • LIGO
  • Issues
  • #1080

Closed
Open
Opened Dec 21, 2020 by Utku Demir@utdemir

Confusing error message when passing a big_map to a curried function.

When compiling below mligo code:

type action = unit
type storage = unit

let mem_set (mem: (int, int) big_map) (ptr: int) : (int, int) big_map =
  let ign = assert (ptr <= 1) in
  Big_map.update ptr (Some 0) mem

let main ((action, storage): action * storage): operation list * storage =
 let ign = mem_set (Big_map.empty: (int, int) big_map) 0 in
 (([] : operation list), storage)

We get the error:

Error(s) occurred while type checking the contract:
Ill typed contract:
  01: { parameter unit ;
  02:   storage unit ;
  03:   code { PUSH int 0
  04:          /* [ int : pair (unit @parameter) (unit @storage) ] */ ;
  05:          EMPTY_BIG_MAP
  06:            int
  07:            int
  08:          /* [ big_map int int : int : pair (unit @parameter) (unit @storage) ] */ ;
  09:          LAMBDA
  10:            (pair (big_map int int) int)
  11:            (big_map int int)
  12:            { /* [ @arg pair (big_map int int) int ] */
  13:              DUP
  14:              /* [ @arg pair (big_map int int) int : @arg pair (big_map int int) int ] */ ;
  15:              CDR
  16:              /* [ int : @arg pair (big_map int int) int ] */ ;
  17:              SWAP
  18:              /* [ @arg pair (big_map int int) int : int ] */ ;
  19:              CAR
  20:              /* [ big_map int int : int ] */ ;
  21:              SWAP
  22:              /* [ int : big_map int int ] */ ;
  23:              PUSH int 1
  24:              /* [ int : int : big_map int int ] */ ;
  25:              SWAP
  26:              /* [ int : int : big_map int int ] */ ;
  27:              DUP
  28:              /* [ int : int : int : big_map int int ] */ ;
  29:              DUG 2
  30:              /* [ int : int : int : big_map int int ] */ ;
  31:              COMPARE
  32:              /* [ int : int : big_map int int ] */ ;
  33:              LE
  34:              /* [ bool : int : big_map int int ] */ ;
  35:              IF { /* [ int : big_map int int ] */ }
  36:                 { PUSH string "failed assertion"
  37:                   /* [ string : int : big_map int int ] */ ;
  38:                   FAILWITH
  39:                   /* [] */ } ;
  40:              SWAP
  41:              /* [ big_map int int : int ] */ ;
  42:              PUSH int 0
  43:              /* [ int : big_map int int : int ] */ ;
  44:              SOME
  45:              /* [ option int : big_map int int : int ] */ ;
  46:              DIG 2
  47:              /* [ int : option int : big_map int int ] */ ;
  48:              UPDATE
  49:              /* [ big_map int int ] */ }
  50:          /* [ lambda (pair (big_map int int) int) (big_map int int) : big_map int int
  51:             : int : pair (unit @parameter) (unit @storage) ] */ ;
  52:          SWAP
  53:          /* [ big_map int int : lambda (pair (big_map int int) int) (big_map int int)
  54:             : int : pair (unit @parameter) (unit @storage) ] */ ;
  55:          APPLY ;
  56:          SWAP ;
  57:          EXEC ;
  58:          DROP ;
  59:          CDR ;
  60:          NIL operation ;
  61:          PAIR } }
At line 55 characters 9 to 14,
big_map type not expected here

Looking at the error message from Michelson typechecking, I think it is caused by trying to capture a big_map from outer scope in a lambda, which is not allowed since big_map's aren't packable. However, to me, the error message does not convey this well, and especially on the larger contracts it is hard to figure out the reason. It might be preferable to have a better error message in this case.

--

Ligo version 0.6.0.

Edited Dec 21, 2020 by Utku Demir
Assignee
Assign to
Check Michelson restrictions
Milestone
Check Michelson restrictions
Assign milestone
Time tracking
None
Due date
None
Reference: ligolang/ligo#1080