"break" does not return to top level from a file load, contrary to its documentation
Nobody has claimed this yet.
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
This issue was triaged from [`bugs/dan/0-debugging-loadPackage`](https://github.com/Macaulay2/M2/blob/388c1ff0ce30d83751dea7bc7eac77fdc1305dd7/bugs/dan/0-debugging-loadPackage), 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
"break" doesn't always escape from loading a file:
Macaulay2, version 1.4.0.1
with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, TangentCone
i1 : loadPackage "Macaulay2Doc"
o1 = Macaulay2Doc
o1 : Package
i2 : loadPackage "Macaulay2Doc"
src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc.m2:2:1:(3):[7]: error: package Macaulay2Doc not reloaded; try Reload => true
src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc.m2:2:1:(3):[7]: --entering debugger (type help to see debugger commands)
src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc.m2:2:1-11:24: --source code:
newPackage ("Macaulay2Doc",
InfoDirSection => "Macaulay2 and its packages",
AuxiliaryFiles => true,
Headline => "Macaulay2 documentation",
Authors => {
{Name => "Daniel R. Grayson", Email => "dan@math.uiuc.edu", HomePage => "http://www.math.uiuc.edu/~dan/"},
{Name => "Michael E. Stillman", Email => "mike@math.cornell.edu", HomePage => "http://www.math.cornell.edu/People/Faculty/stillman.html"}
},
HomePage => "http://www.math.uiuc.edu/Macaulay2/",
Version => version#"VERSION")
ii3 : break
--loading the Macaulay2 documentation from src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc/
src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc/doc.m2:4:1:(3):[15]: error: item to be documented comes from another package: Macaulay2Doc :: length
src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc/doc.m2:4:1:(3):[15]: --entering debugger (type help to see debugger commands)
src/M2/trunk/M2/Macaulay2/packages/Macaulay2Doc/doc.m2:4:1-6:15: --source code:
document {
Key => "length",
Headline => "length"
```
### Where it stands today
The documented behaviour and the actual behaviour disagree. `Core/code.m2:263` documents
> `break` -- leave the debugger, returning to top level
but `break` leaves the debugger and **resumes the file past the failing expression**, so the rest of
the file runs.
### Four lines reproduce it
Load a file containing a function that calls `error`, plus anything after it; at the debugger prompt
type `break`; the remaining expressions in the file are evaluated.
Dan's transcript in the file is the visible symptom of that: loading `Macaulay2Doc` twice errors,
`break` carries on into the next error *in the same file*, re-enters the debugger, and the session is
left sitting at `ii` — a prompt the user cannot easily escape.
### Distinct from #1928
Worth stating, since the two look alike: `continue` re-runs the failing expression and therefore
loops, while `break` skips it and continues. The two commands differ, and **neither matches its
description** — so a fix should probably settle what each is meant to do rather than adjust one of
them.
`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
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
Start with the `break` documentation at `Core/code.m2:263`, then reproduce the four-line file-load case described in the issue. Trace the debugger and file-loading behavior to determine how `break` and `continue` should differ; done means the documented top-level behavior is restored without leaving later file expressions running.
Written by the indexing model from the issue text.
Assessment
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100