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

Remove by-mut-ref mode altogether #3513

Closed
nikomatsakis opened this issue Sep 17, 2012 · 3 comments
Closed

Remove by-mut-ref mode altogether #3513

nikomatsakis opened this issue Sep 17, 2012 · 3 comments
Labels
A-type-system Area: Type system I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone

Comments

@nikomatsakis
Copy link
Contributor

The handling of "by mutable reference" parameters is unsound because it doesn't affect variance. This is not news. One place we take advantage of this is vec::push(), which has the type

fn push<T>(&vec: ~[const T], +val: T) { ... }

This is unsound because we accept any sort of vector for the argument vec, but the type system only guarantees that we'll write back a const vector. I thought this was basically harmless, since vectors are uniques, but I forgot that it also implies that we will be covariant with respect to T. When combined with regions, this leads to bugs like #3501. However you can create problems without regions too. Any place where we have subtyping.

Anyway, we had always planned to remove by-mut-ref mode as part of the general "de-moding", but I think we should up the priority for this particular mode. It is not that widely used in any case, though vec::push() is certainly frequent. I am checking out how hard it will be to just purge it altogether.

@graydon
Copy link
Contributor

graydon commented Sep 17, 2012

Yeah, this is the really major one.

@catamorphism
Copy link
Contributor

I'm not sure if we decided this was for 0.4 or not, but I'll try to do it.

@ghost ghost assigned catamorphism Oct 2, 2012
@catamorphism
Copy link
Contributor

I am working on this, but ran into a strange bug where apparently, the code after a nested pure fn gets treated as if it should be pure. I'll try to isolate it tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

3 participants