Skip to content

Tag all the fields of a mutable item mutable #2649

@ijklam

Description

@ijklam

Currently, the semantic token of fields in a mutable item (e.g. var variable, mutable pointer) is property, but as the field can be change, it should have a mutable modifier in its semantic token, same as var variables. Though the mutable modifier takes no effect for now, unless we implement https://codeberg.org/ziglang/vscode-zig/issues/492.

For example:

fn f() void {
  var a: struct {
    x: u32,
  } = .{ .x = 1 };
  const b = &a;

  _ = a.x; // `x` here should be taggeg `mutable`
  _ = b.*.x; // `x` here should be taggeg `mutable`
}

Moreover, methods that accepts self: *@This() can also tagged as mutable, to indicate that it may change the fields of self in the method body.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions