Repository navigation
Commit e27a4fb
committed
fix: Enforce the adaptive indexing refusal, and three review follow-ups
Four findings from review on #349, all against bfa28bc.
`__getitem__` now rejects an adaptive space explicitly. Review pointed out that
it resolved a negative index against `self.len` — the count `__len__` refuses to
report for an adaptive space, on the grounds that it is not knowable — and that
`it[-1]` therefore declined only because `get` happened to decline downstream.
Confirmed by reading it: `self.len` is captured unconditionally at construction
and `__getitem__` had no adaptive check. Since 0.6.0 just extended `get` to
contiguous chunked spaces, a later extension to adaptive would have made `it[-1]`
answer against a count `len()` still withholds. The guard makes the documented
behaviour the enforced one and lets the message name the reason.
The message is now the pure-Python reference's, verbatim. The type stays
`IndexError` rather than moving to v0's bare `LookupError`: `IndexError` is a
`LookupError` subclass, so a caller catching either type is served by both
implementations, while changing the type would break anyone catching
`IndexError`. Full type parity is a breaking change and is not smuggled into a
dependency bump. The spec now records the divergence, which review noted the
rewritten text had made read as though the area were at parity.
`test_indexing_observes_the_override` had a docstring the previous commit
falsified: it said random access needs a non-sequential space and that a
contiguous chunked space is always sequential, then pointed at "the test below"
— which is now the test proving both clauses wrong. Replaced with the reason the
NONCONTIGUOUS choice actually still holds, which review identified correctly: it
renders a single-task chunk as a bare `1` where CONTIGUOUS renders `1-1`, and
that is what the assertions depend on.
`scripts/check_third_party_licenses.sh` no longer creates a second temp file.
The `$generated.eol` sibling the previous commit introduced was not registered
with the `trap`, so it leaked if the script died between the redirect and the
`mv`. Folding `sed` into the redirect that already builds `$generated` drops the
file, the `mv` and the portability caveat at once. Review suggested `tr -d`;
kept `sed 's/\r//'` because `tr -d` also deletes a CR that is not a line ending,
and the point here is EOL normalization. The script still reports the file up to
date, so the output is byte-identical.
Verified: 5567 passed, 24 skipped, 3 xfailed with the 94% coverage gate;
cargo clippy --all-targets -D warnings, cargo fmt, ruff, black, mypy clean;
scripts/check_third_party_licenses.sh reports up to date. Removing the new guard
fails `test_an_adaptive_space_still_refuses_indexing` and nothing else, from a
green baseline of 18 in that class.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>1 parent 65da216 commit e27a4fb
4 files changed
Lines changed: 62 additions & 19 deletions
File tree
- rust-bindings/src/model
- scripts
- specs
- test/openjd/model_v1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
217 | 237 | | |
218 | 238 | | |
219 | 239 | | |
| |||
225 | 245 | | |
226 | 246 | | |
227 | 247 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | 248 | | |
236 | 249 | | |
237 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 161 | + | |
164 | 162 | | |
165 | 163 | | |
166 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1201 | 1201 | | |
1202 | 1202 | | |
1203 | 1203 | | |
1204 | | - | |
| 1204 | + | |
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1208 | 1222 | | |
1209 | 1223 | | |
1210 | 1224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
817 | 817 | | |
818 | 818 | | |
819 | 819 | | |
820 | | - | |
821 | | - | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
822 | 824 | | |
823 | 825 | | |
824 | 826 | | |
| |||
863 | 865 | | |
864 | 866 | | |
865 | 867 | | |
866 | | - | |
867 | | - | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
868 | 878 | | |
869 | 879 | | |
870 | | - | |
| 880 | + | |
871 | 881 | | |
872 | 882 | | |
873 | | - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
874 | 892 | | |
875 | 893 | | |
876 | 894 | | |
| |||
0 commit comments