varpower::power(a, 0, output) appends the identity to an existing output
Nobody has claimed this yet.
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
In `M2/Macaulay2/e/monomials/ExponentList.cpp`, the zero-power branch uses `push_back(1)` rather than replacing the output, unlike the nonzero-power branch.
```cpp
int a[] = {3, 0, 2};
varpower::Vector output{3, 1, 4};
varpower::power(a, 0, output);
```
Expected: output is `[1]`, representing a^0 = 1.
Actual: `[3,1,4,1]`; reading the encoded monomial still gives y^4.
Reproduced with an intended-result GoogleTest assertion in the Debug engine build at c156fdcba4 (Apple Clang 21). Reusing the output for a nonzero power replaces it correctly. No production changes.
### Failing unit-test blocks
- `TEST(ExponentList, DISABLED_zeroPowerReplacesOutput)` in `M2/Macaulay2/e/unit-tests/ExponentListTest.cpp`.
These regressions were explicitly run and confirmed to fail against the current implementation. They assert the intended corrected behavior and remain disabled in normal runs until the defect is fixed.
Run from the CMake build directory after building `M2-unit-tests`:
```sh
./Macaulay2/e/M2-unit-tests \
--gtest_also_run_disabled_tests \
--gtest_filter='ExponentList.DISABLED_zeroPowerReplacesOutput'
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read M2/Macaulay2/e/monomials/ExponentList.cpp and the disabled ExponentList.DISABLED_zeroPowerReplacesOutput test in M2/Macaulay2/e/unit-tests/ExponentListTest.cpp. From the CMake build directory, run the provided M2-unit-tests command first. Done means the zero-power case passes with output [1] while existing nonzero-power behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100