Skip to content

inconsistent behaviour regarding @mut and &mut in managed and borrowed reference types #5720

Closed
@dhardy

Description

@dhardy

Using @int instead of @mut int in a type causes a compile error, but using &int instead of &mut int does not.

let o = @mut 5;
let mut m : @int = o;       // error: mismatched types: expected `@int` but found `@mut <VI5>` (values differ in mutability)
let mut b : &int = o;       // compiles (with type '&int' or '&mut int')?
let mut c : &int;           // to contrast...
c = o;      // error: mismatched types: expected `&int` but found `@mut int` (expected &-ptr but found @-ptr)

This could be intended behaviour, but I presume not since as I understand it variable typing is either automatic (from the rvalue) or explicit, not some mixture of the two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions