Skip to content

Can write to immutable parts of a type. #118

Closed
@froystig

Description

@froystig

Each pair of lines in the following function:

fn main() {
  let vec[int] v = vec(1, 2, 3);
  v.(1) = 4;

  let tup(int) t = tup(1);
  t._0 = 5;

  let rec(int x) r = rec(x=1);
  r.x = 6;
}

shouldn't make it past the typechecking phase, but do. Also, the following object definition makes it past the typechecker:

obj objy(int x) {
    fn foo() -> () {
        x = 5;
    }
}

but should not. Fix the typechecker to disallow writing to immutable type-parts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions