vars generates variable names that .. cannot invert
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
This issue was triaged from [`bugs/dan/1-dot-dot-2`](https://github.com/Macaulay2/M2/blob/388c1ff0ce30d83751dea7bc7eac77fdc1305dd7/bugs/dan/1-dot-dot-2), one of the 857 files removed from the pre-GitHub `bugs/` tree by [`d2c8d27826`](https://github.com/Macaulay2/M2/commit/d2c8d27826) and catalogued in [#36](https://github.com/Macaulay2/M2/issues/36). **The commentary below was written by Claude (Claude Opus 5, via Claude Code)**, not by @d-torrance, whose account posted it -- please weigh it accordingly.
### The original file, verbatim
```text
i10 : X11 .. a
stdio:10:5:(1):[0]: error: X11 is not one of the symbols known to 'vars'
i11 : vars (-11)
o11 = X11
o11 : Symbol
```
### Where it stands today
Reproduces cold, and the order of the file's two lines matters — which is worth knowing before testing it.
```m2
i1 : X11 .. a
error: 'X11' is not one of the symbols known to 'vars'
i2 : vars(-11)
o2 = X11
i3 : X11 .. a
o3 = (X11, X10, ..., X1, a) -- works now
```
So `X11 .. a` fails in a fresh session and succeeds only after `vars(-11)` has memoized into
`varIndices`. Running the file's lines in the *other* order reads as fixed.
### The cause: a one-way map
`varName` (`indeterminates.m2:8-13`) defines the whole naming scheme — `X` for negative indices,
`x` for indices ≥ 52 — while `reverseVars` (`:24-33`) inverts only single letters,
`match("^[a-zA-Z]$", s)` at `:28`, plus whatever a prior `vars ZZ` call happened to register.
So `vars` generates names it cannot invert. It is not only the negative case: `vars(52..54)` is
`(x0, x1, x2)` and `x0 .. x2` fails the same way.
### The fix is the two missing inverses
`^X([0-9]+)$` and `^x([0-9]+)$`. They cannot collide with the single-letter case, since `x` alone is
index 23 and `x0` is index 52.
### Distinct from the other `..` issues
**#4510** and **#2020** are about `..` returning the wrong *type*, not about failing to resolve a name.
`open` · disposition `issue` · source of truth: [`bug-triage/catalog.tsv`](https://github.com/d-torrance/M2/blob/bug-triage/bug-triage/catalog.tsv)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in indeterminates.m2 at varName and reverseVars, then reproduce the ordering-sensitive examples in a fresh Macaulay2 session. Verify that generated names such as X11 and x0 can be resolved by .. without requiring an earlier vars call, while preserving the existing single-letter behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100