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

Prevent modification of const ref varargs, too #25902

Merged
merged 8 commits into from
Oct 9, 2024

Conversation

lydia-duncan
Copy link
Member

@lydia-duncan lydia-duncan commented Sep 6, 2024

Resolves #25901

Modifies the same place as the PRs for const and const in, but additionally needed a fix for moveSetConstFlagsAndCheck because the local tuple variable was using a PRIM_GET_MEMBER_VALUE instead of a PRIM_GET_MEMBER (though only in the case where it returns a ref).

Also updates a couple of tests that were impacted by the change:

  • The varargs array test could reasonably be considered fulfilling the promise of the deprecation message it encountered previously.
  • Futurizes the DataFrame test. We believe it to be okay because the failure mode is accurate (we think chpl__buildAssociativeArrayExpr should still be generally using const for its varargs, and copying an owned class does modify the original) and was not caught before this change. Add test locking in that there's an alternate way to create an associative array of owned classes that doesn't use the associative array literal syntax. I also opened [Bug]: support for associative array literals with owned classes depended on violating const checks for varargs #26035 to track the future

Add tests locking in the fix for const ref. Covers both queried and unqueried numbers of arguments.

Modifies the same place as the PRs for const and const in, but additionally
needed a fix for `moveSetConstFlagsAndCheck` because the local tuple variable
was using a `PRIM_GET_MEMBER_VALUE` instead of a `PRIM_GET_MEMBER`.

We'll see if that has broader consequences, though.

----
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
Covers both queried and unqueried numbers of arguments

----
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
@lydia-duncan

This comment was marked as resolved.

Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
…works

This test failed due to us now (accurately) detecting that
`chpl__buildAssociativeArrayExpr` violates the const-ness of the varargs for
owned arguments.  In talking with Michael, we decided it was okay for this to
get futurized as a result, and added a version of the test that does not fail,
showing that you can still create associative arrays that store owned classes
(just not using associative array literals)

----
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
…e merged

This is basically the same thing as removing the deprecated behavior (for the
purpose of this particular test, we need to perform the behavior update more
generally still), so I don't think the change is concerning

----
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
----
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
…LUE`

Michael pointed out that `PRIM_GET_MEMBER_VALUE` can situationally return a ref
or a value and we don't want to apply the const-ness in the value case (as it
will be a copy and thus independent of the behavior of the `const` source).  So
ensure that the result of the call will be a ref before propagating the `const`.

This passed the normally impacted tests locally, will run a full paratest as
well

----
Signed-off-by: Lydia Duncan <lydia-duncan@users.noreply.github.com>
@lydia-duncan lydia-duncan merged commit 809f6d9 into chapel-lang:main Oct 9, 2024
7 checks passed
@lydia-duncan lydia-duncan deleted the fixConstRefModsToo branch October 9, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: const ref attached to vararg formal arguments allows their modification
2 participants