Skip to content

Fix autoloading logic - #78

Merged
raxod502 merged 1 commit into
mainfrom
rr-autoload-logic
Sep 7, 2026
Merged

raxod502 merged 1 commit into
mainfrom
rr-autoload-logic

Conversation

@raxod502

@raxod502 raxod502 commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

There was a subtle bug here. The el-patch--deftype-stub-setup was checking if el-patch-deftype was already defined, before overwriting it with a stub. Good, but that check was wrong, because el-patch-deftype was always already defined, so it never did anything. In the case of el-patch not having been loaded yet, el-patch-deftype was defined as an autoload. This was misinterpreted as it having been fully defined, and hence not needing to be overwritten as a stub, leading to the autoloaded invocations of el-patch-deftype later in the file causing the whole file to actually be loaded.

I found out about this, while investigating radian-software/straight.el#1295. This patch doesn't address that problem, but the behavior of el-patch always being loaded during autoloads activation was definitely wrong, so I fixed that.

The new behavior has the stub check specifically if el-patch-deftype is defined as an autoload. If so, it overwrites the autoload stub with its own non-autoload stub. Then there is a new teardown function evaluated later in autoloads, which restores the original autoload definition if it was overwritten.

Also, I autoloaded el-patch-variant, which is read by the macroexpansion of el-patch--definition and thus needed at runtime. Having el-patch always loaded during autoloads activation was masking that bug.

@raxod502
raxod502 merged commit 6eefe13 into main Sep 7, 2026
5 checks passed
@raxod502
raxod502 deleted the rr-autoload-logic branch September 7, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant