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

[Bug]: support for associative array literals with owned classes depended on violating const checks for varargs #26035

Open
lydia-duncan opened this issue Oct 3, 2024 · 0 comments

Comments

@lydia-duncan
Copy link
Member

lydia-duncan commented Oct 3, 2024

Summary of Problem

Description:
When #25902 gets merged, it will improve const and const ref checking for varargs. As a result, trying to create a default associative array literal with owned classes will trigger constness errors, because chpl__buildAssociativeArrayExpr takes const varargs but tries to copy the arguments (and copying an owned object modifies the object, making it not a const operation).

Consulting with Michael, it seems like we probably want chpl__buildAssociativeArrayExpr to continue taking its arguments by const for the most part. It may make sense to carve out a special case for handling owned classes, but we were concerned that would be too much to handle at the moment, so decided to futurize the test that was triggering the error for now until resolving it becomes a priority (e.g. if a user runs into it).

Is this issue currently blocking your progress?
no, this can be worked around by explicitly declaring the domain for the associative array ahead of time and populating the contents of the array after its initial declaration (see HelloDataFrame-createDomFirst.chpl, which will be added by #25902)

Steps to Reproduce

Associated Future Test(s):
test/library/draft/DataFrames/psahabu/HelloDataFrame.chpl #25902 (modified)

Configuration Information

  • Output of chpl --version: chapel 2.3 (pre-release)
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
CHPL_TARGET_PLATFORM: darwin
CHPL_TARGET_COMPILER: clang
CHPL_TARGET_ARCH: arm64
CHPL_TARGET_CPU: native
CHPL_LOCALE_MODEL: flat
CHPL_COMM: none
CHPL_TASKS: qthreads
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
CHPL_GMP: bundled
CHPL_HWLOC: bundled
CHPL_RE2: bundled
CHPL_LLVM: none *
CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version: N/A
  • (For Cray systems only) Output of module list: N/A
lydia-duncan added a commit that referenced this issue Oct 9, 2024
[reviewed by @mppf]

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 #26035 to track the future

Add tests locking in the fix for const ref. Covers both queried and
unqueried numbers of arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant