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

Fix inaccurate documentation in member function mutability. #6065

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

entropylost
Copy link
Contributor

It previously stated that changes would simply not be applied, which is not the case based on the playground:

struct Foo {
    int count;
    void setCount(int x) {
        count = x;
    }
}

void test() {
    Foo f;
    f.setCount(1);
}

Gives this compile error

USER error: /user.slang(4): error 30011: left of '=' is not an l-value.
        count = x;
              ^
/user.slang(4): note 30049: a 'this' parameter is an immutable parameter by default in Slang; apply the `[mutating]` attribute to the function declaration to opt in to a mutable `this`
(0): error 39999: import of module 'user' failed because of a compilation error
(0): fatal error 39999: compilation ceased

It may also be worth removing the "for gpu performance considerations" since it doesn't impact performance at all.

@entropylost entropylost requested a review from a team as a code owner January 11, 2025 21:54
@CLAassistant
Copy link

CLAassistant commented Jan 11, 2025

CLA assistant check
All committers have signed the CLA.

@csyonghe csyonghe merged commit 11575d2 into shader-slang:master Jan 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants