Macaulay2 / Macaulay2/M2

Comparing complex numbers with < or ? silently answers instead of erroring

Open
#4,544 0 comments 0 reactions 0 assignees View on GitHub
bugs directory Interpreter
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

This issue was triaged from [`bugs/dan/0.5-compare-CC-CC`](https://github.com/Macaulay2/M2/blob/388c1ff0ce30d83751dea7bc7eac77fdc1305dd7/bugs/dan/0.5-compare-CC-CC), 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
This sort of comparison of complex numbers is not mathematically meaningful:

i35 : 1+2*ii < 2. * ii

o35 = false

i36 : 1+2*ii ? 2. * ii

o36 = >

o36 : Keyword

See "compare(...)" in gmp.d and compare(left:Expr,right:Expr) in actors3.d.
Make it give an error message, as returning "incomparable" would allow z
```

So an unordered pair of complex numbers compares silently rather than erroring.

### The file's reasoning, which is the useful part

Dan explicitly argues against the softer fix: returning `incomparable` from `?` would still let `z < w`
succeed with the answer `false`, which *deceives* the user — a false answer is worse than a refusal,
because nothing signals that the question was meaningless. Hence an error.

### Where the code is

`compare(...)` in `d/gmp.d` and `compare(left:Expr, right:Expr)` in `d/actors3.d`, both named in the
file.

### Worth noting alongside

`?` already has an `incomparable` result and uses it for genuinely unordered cases such as sets, so the
machinery for "no answer" exists — the decision is whether comparison of complex numbers should use it
or raise, and the file argues for raising because of the `<` case.

`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

Reproduce the two examples in the issue, then read compare(...) in d/gmp.d and compare(left:Expr, right:Expr) in d/actors3.d. Trace how unordered complex-number comparisons are handled, including the existing incomparable result for ?. Done means both < and ? report an error rather than silently returning false or >.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.