Skip to content

Typestate 2 #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 17, 2011
Merged

Typestate 2 #380

merged 7 commits into from
May 17, 2011

Conversation

catamorphism
Copy link
Contributor

Apologies in advance for having lots of changes in a big commit. I've spent so much time on git yak-shaving the past week that I don't want to mess with it anymore =P

…, so I added one (though this wasn't causing the problem I was seeing...
… annotations

* Reorganized typestate into several modules.

* Made typestate check that any function with a non-nil return type
  returns a value. For now, the check is a warning and not an error
  (see next item).

* Added a "bot" type (prettyprinted as _|_), for constructs like be, ret, break, cont, and
  fail that don't locally return a value that can be inspected. "bot"
  is distinct from "nil". There is no concrete syntax for _|_, while
  the concrete syntax for the nil type is ().

* Added support to the parser for a ! annotation on functions whose
  result type is _|_. Such a function is required to have either a
  fail or a call to another ! function that is reached in all control
  flow paths. The point of this annotation is to mark functions like
  unimpl() and span_err(), so that an alt with a call to err() in one
  case isn't a false positive for the return-value checker. I haven't
  actually annotated anything with it yet.

* Random bugfixes:

* * Fixed bug in trans::trans_binary that was throwing away the
    cleanups for nested subexpressions of an and or or
    (tests: box-inside-if and box-inside-if2).

** In typeck, unify the expected type arguments of a tag with the
   actual specified arguments.
get_os and get_arch were failing to return a value in the error
case; they were also assuming that strings are indexed from 1. No
idea how they ever worked, but anyway, fixed.
@catamorphism
Copy link
Contributor Author

I think this will require a new stage1 snapshot (there's code in the "Started adding support for return checking..." patch that triggers bugs in stage0). The procedure scares me, though.

@graydon graydon merged commit 41b7af9 into rust-lang:master May 17, 2011
@graydon
Copy link
Contributor

graydon commented May 17, 2011

Integrated. Thanks.

kazcw pushed a commit to kazcw/rust that referenced this pull request Oct 23, 2018
dlrobertson pushed a commit to dlrobertson/rust that referenced this pull request Nov 29, 2018
Add impl trait and remove others from undocumented list
dlrobertson pushed a commit to dlrobertson/rust that referenced this pull request Nov 29, 2018
Sorry, missed one in my last commit.  Also, rust-lang#380 recently removed the link, but
not the actual entry.
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Oct 26, 2020
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this pull request Mar 7, 2023
* handle insertvalue array

* add tests

* fix test
calebzulawski added a commit to calebzulawski/rust that referenced this pull request Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants