Skip to content

Classes: handle typestate correctly in ctors #2293

Description

@catamorphism

Enforce these invariants in typestate:

"The constructor must initialize all fields of the object and cannot call any methods on self until it has done so." (currently there's no check that the ctor initializes fields, even)

"After calling a method on self, the constructor is not allowed to mutate any of its immutable fields."

Activity

  1. catamorphism commented on May 11, 2012

    @catamorphism
    ContributorAuthor

    Blocked on #2376 -- if that RFC gets accepted, we'll be able to eliminate ctors and there'll be no need for special cases in typestate.

  2. nikomatsakis commented on May 29, 2012

    @nikomatsakis
    Contributor

    this is implemented in the new liveness code. if I'd realized it wasn't implemented at all in typestate I probably wouldn't have bothered, but oh well. =)

  3. removed their assignment
    on Jun 16, 2014
  4. added a commit that references this issue on Sep 22, 2022
  5. added a commit that references this issue on Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions