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

[Task]: Require locks when assigning to a field of an isolated object in the init method after all the fields have been initialized #41043

Open
MaryamZi opened this issue Jul 18, 2023 · 0 comments
Labels
Priority/High Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Task

Comments

@MaryamZi
Copy link
Member

Description

With the fix (#40757) for #40736, we will be making it an error when self of an isolated object is accessed outside a lock statement other than to set a value for a field.

But according to the spec, once all the fields are initialized, even subsequent assignments to fields need to happen within lock statements.

Given that not using locks here won't cause any correctness issues (since we require isolated expression when assigning anyway) and the task re-prioritization along with the extent of changes required (need to duplicate dataflow analyzer-like logic and address issues in the existing logic), we have deferred this for now.

Describe your task(s)

isolated class Foo {
    private int[][] x;

    isolated function init(int[][] x, int[] y) {
        self.x = x.clone(); // OK

        self.x.push(y); // error now because outside lock

        // Should also be an error according to the spec
        self.x = x.clone();
    }
}

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@MaryamZi MaryamZi added Type/Task Priority/High Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority/High Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Task
Projects
None yet
Development

No branches or pull requests

1 participant