feat: Add WhereDepth user preference for stack depth#6261
feat: Add WhereDepth user preference for stack depth#6261limakzi wants to merge 1 commit intogap-system:masterfrom
Conversation
| if false then Stabilizer; fi; | ||
| ^ | ||
|
|
||
| # |
There was a problem hiding this comment.
I'm not sure, its best place.
There was a problem hiding this comment.
Pull request overview
Adds a new core GAP user preference (WhereDepth) to control the default stack depth used by Where / WhereWithVars when called with no explicit argument (notably via the default OnBreak handler), keeping the default behavior at 5.
Changes:
- Declare new
WhereDepthuser preference (default5, non-negative integer). - Use
UserPreference("WhereDepth")as the default depth inWhereandWhereWithVars. - Add an installation test that verifies the preference exists and can be changed.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/init.g |
Declares the new WhereDepth user preference with default/check logic. |
lib/error.g |
Switches Where / WhereWithVars default depth from constant 5 to UserPreference("WhereDepth"). |
tst/testinstall/error.tst |
Adds a basic regression test for reading/setting WhereDepth. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| BIND_GLOBAL("WhereWithVars", function(arg) | ||
| local depth; | ||
| if LEN_LIST(arg) = 0 then | ||
| depth := 5; | ||
| depth := UserPreference("WhereDepth"); | ||
| else | ||
| depth := arg[1]; |
There was a problem hiding this comment.
UserPreference("WhereDepth") can return fail (preference not declared yet) or a non-integer (since SetUserPreference does not enforce the declared check). In both cases, WHERE_INTERNAL/WHERE will error when comparing depth <= 0, potentially breaking error handling (notably during startup, since lib/error.g is read in lib/read1.g before preferences are declared in lib/init.g). Consider falling back to 5 when the preference is fail or not a non-negative integer.
| BIND_GLOBAL("Where", function(arg) | ||
| local depth; | ||
| if LEN_LIST(arg) = 0 then | ||
| depth := 5; | ||
| depth := UserPreference("WhereDepth"); | ||
| else | ||
| depth := arg[1]; |
There was a problem hiding this comment.
Same as above for Where: UserPreference("WhereDepth") may be fail or non-integer (and during early startup may be undeclared), which will cause WHERE_INTERNAL/WHERE to throw when doing integer comparisons. Add a defensive fallback to the previous default (5) if the preference value is not a non-negative integer.
Adds a
WhereDepthuser preference that controls the default number of stack frames shown byWhereandWhereWithVarswhen called without an explicit depth argument (i.e. in the defaultOnBreakhandler).Previously this was hardcoded to 5.
The default remains 5, so existing behaviour is unchanged.
Fixes #6210