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 oslc missing a write error on function parameter #1417

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Oct 1, 2021

Fixes #1416

In OSL, function parameters must be marked as output or they are not
supposed to be writable. In issuing errors when a write is performed on
something not writable, we missed an interesting case:

void g(output float b) {
    b = 1;  // ok, since b is marked as output
}

void f(float a) {
    g(a);  // <--- should be disallowed, g is writing to f's non-output param
}

float x;
f(x);

This patch catches cases like these. The new error looks like this:

test.osl:22: error: cannot write to non-output parameter "a", as passed to function g() as arg 1 (output parameter "b")

Signed-off-by: Larry Gritz [email protected]

Fixes 1416

In OSL, function parameters must be marked as `output` or they are not
supposed to be writable. In issuing errors when a write is performed on
something not writable, we missed an interesting case:

```
void g(output float b) {
    b = 1;  // ok, since b is marked as output
}

void f(float a) {
    g(a);  // <--- should be disallowed, g is writing to f's non-output param
}

float x;
f(x);
```

This patch catches cases like these. The new error looks like this:

`test.osl:22: error: cannot write to non-output parameter "a", as passed to function g() as arg 1 (output parameter "b")`

Signed-off-by: Larry Gritz <[email protected]>
@lgritz
Copy link
Collaborator Author

lgritz commented Oct 5, 2021

@lkerley or others, does this seem ok? Is the form of that error message helpful?

@lgritz
Copy link
Collaborator Author

lgritz commented Oct 5, 2021

Lee said LGTH

@lgritz lgritz merged commit 0d1d2de into AcademySoftwareFoundation:master Oct 5, 2021
@lgritz lgritz deleted the lg-output branch October 8, 2021 20:33
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.

oslc doesn't notice a violation of function output param rules
1 participant