Skip to content
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

Typestate too strict for multi-var let #824

Closed
marijnh opened this issue Aug 16, 2011 · 3 comments
Closed

Typestate too strict for multi-var let #824

marijnh opened this issue Aug 16, 2011 · 3 comments

Comments

@marijnh
Copy link
Contributor

marijnh commented Aug 16, 2011

I'd like this to work:

let x = 10, y = x;

Currently, the initializer for y is checked in an environment where neither variable has been defined, so typestate rejects this line.

@ghost ghost assigned catamorphism Aug 16, 2011
@catamorphism
Copy link
Contributor

For simplicity, I actually prefer the current behavior.

What's the static semantics of let x = y, y = x; -- should it be rejected by typestate, or should it compile but diverge at runtime?

@marijnh
Copy link
Contributor Author

marijnh commented Aug 17, 2011

The (recently revised) resolver will reject this. Variables can no longer be used before they are initialized, and series of variables in a single let behave as if they are defined one after the other (i.e Common Lisp's let* form, not let). To do a name swap, you can do 'let (x, y) = (y, x);' (where x and y were previously bound).

@catamorphism
Copy link
Contributor

Ah, ok. As long as the resolver checks for obviously non-well-founded definitions, I guess I'm ok with implementing your original suggestion.

keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
Fixes and test for x86_64-unknown-linux-gnux32

This fixes all libc tests and almost all rustc tests (3 libstd tests and one run-pass test fails).

Fixes rust-lang/libc#816
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
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

No branches or pull requests

2 participants