Repository navigation
Conversation
The option was truncated and cast to an unsigned number, so 8, 9, -1 and -0.5 were accepted and a number came back. Excel answers #VALUE! for any option outside 0 to 7, while a fraction inside it (7.9) still truncates. Fixes storytold#4270.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Upstream PR: storytold#4347 Head: ceec99d
Merges the zcode-pr-transfer branch (61 commits transferring open, not-yet-merged upstream PRs into our fork) into main. Docs (docs/ui-parity.md, docs/file-format-parity.md) resolved in favor of main's current changelog state; code from all transferred PRs carried over cleanly. Commits carried over (21 from this session + 40 earlier transfers): storytold#4408, storytold#4405, storytold#4406, storytold#4386, storytold#4379, storytold#4378, storytold#4376, storytold#4375, storytold#4373, storytold#4370, storytold#4369, storytold#4348, storytold#4347, storytold#4345, storytold#4344, storytold#4343, storytold#4341, storytold#4340, storytold#4337, storytold#4336, storytold#4318, storytold#4316, storytold#4315, storytold#4312, storytold#4310, storytold#4307, storytold#4306, storytold#4305, storytold#4303, storytold#4298, storytold#4295, storytold#4287, storytold#4286, storytold#4257, storytold#4256, storytold#4254, storytold#4252, storytold#4251, storytold#4248, storytold#4244, storytold#4243, storytold#4229, storytold#4228, storytold#4227, storytold#4225, storytold#4221, storytold#4220, storytold#4219, storytold#4217, storytold#4424, storytold#4423, storytold#4420, storytold#4419, storytold#4418, storytold#4414, storytold#3617, storytold#2642, storytold#2556, storytold#2321
Fixes #4270
What was wrong
subtotalincrates/calc/src/eval/reference_fns.rsread AGGREGATE'soptionsargument asn.trunc() as u32:Native Excel returns
#VALUE!for any option outside 0 to 7, as the issue shows. That covers a typed value, text such as"8", and a value from a cell. A fraction inside the range still truncates (0.5, 6.9, 7.1 and 7.9 match in the issue).What changed
An option is accepted when
0 ≤ n < 8and then truncated as before; anything else returns#VALUE!. Errors in the option argument still propagate. SUBTOTAL, which has no options argument, isn't touched.QA report
Main vs branch, end to end (
gridcraft-cli run, real cells)The cells are built with
cell.set, printed, saved to.xlsx, and reopened withgridcraft-cli cat.mainis agridcraft-clibuilt fromorigin/main(19f07f3a); the branch is this PR (ceec99d7). The Excel column is the issue's native Excel 16.0 result; I didn't run Excel myself.Setup:
A1:A2= 10, 20;C1= −1,C2= 8,C3= 7;D1==SUBTOTAL(9,A1:A2), a genuine nested subtotal.=AGGREGATE(9,8,A1:A2)=AGGREGATE(9,7,A1:A2)=AGGREGATE(9,9,A1:A2)=AGGREGATE(9,-1,A1:A2)=AGGREGATE(9,-0.5,A1:A2)=AGGREGATE(9,"8",A1:A2)=AGGREGATE(9,C1,A1:A2)(−1 from a cell)=AGGREGATE(9,C2,A1:A2)(8 from a cell)=AGGREGATE(9,0.5…),6.9,7.1,7.9=AGGREGATE(9,8,A1:A2,D1)(with a nested subtotal)=AGGREGATE(9,0,A1:D1)(option 0 skips the nested D1)=AGGREGATE(9,4,A1:D1)(option 4 keeps it)=AGGREGATE(14,8,A1:A2,1)=AGGREGATE(14,-1,A1:A2,1)=AGGREGATE(14,7,A1:A2,1)Both builds reopened their
.xlsxwith the same 18 values.gridcraft-cli checkon the branch's file: 19 formula cells, 19 matched, round trip 0 of 1 files differ.With
gridcraft-cli eval:=AGGREGATE(9,8,{10,20})=AGGREGATE(9,-0.5,{10,20})=AGGREGATE(4,8,{10,20})=AGGREGATE(9,7.9,{10,20})=AGGREGATE(9,8)/=AGGREGATE(99,8,{10,20})=SUBTOTAL(9,{10,20})Test
tests::aggregate_refuses_options_outside_0_to_7(crates/calc/src/tests.rs) checks:"8", and −1 and 8 from cells, with SUM and with LARGE: all#VALUE!;Negative control
With the range check removed (on top of
ceec99d7, then restored withgit checkout), the test fails at=AGGREGATE(9,8,A1:A2): leftNumber(30.0), rightError(Value).Gate (macOS arm64)
cargo fmt --all -- --checkcargo clippy -p gridcraft-calc -p gridcraft-functions -p gridcraft-engine --all-targets -- -D warningscargo test -p gridcraft-calc -p gridcraft-functions -p gridcraft-engineNot covered
function_numandoptionsare invalid:function_numis still read first (=AGGREGATE(99,8,…)is#VALUE!either way).cargo xtask ci: I didn't run the fullcargo xtask ci(wasm, layers, the other crates).Summary by CodeRabbit
AGGREGATEfunction’s options. Values from 0 through 7 are accepted after truncation, while values outside that range now return#VALUE!. This also applies to negative fractions and invalid text or cell-referenced values.