Make sophia error when attempting state updates without put()

Picturing following contract:

contract Test =

    record state = 
      {
          test: int
      }

    entrypoint init() =
        { test = 2 }

    stateful entrypoint set() =
        state{test = 3}

    entrypoint get() =
        state.test

As the state record is reserved anyway, couldn’t we qualify what set() is doing an attempted state update and throw an error for missing the use of the put() function ? Or is there some side case this would technically be a false-hit for ? @radrow @hanssv.chain @ulfnorell

Since you are allowed to use the state record like a normal record (like you do in get) it would be tricky to do in general. You could imagine not being allowed to say that a function is stateful unless it really is - or maybe a warning in that case. It would not stop users from being stupid though, unfortunately :slight_smile:

3 Likes