akbasic_environment_set_label() files into the active scope, not the root
#9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md §6 item 26 (at
9151438)src/environment.c:246walks up untilobj->runtime->environment == obj, which is the currentlyexecuting scope, despite the comment above it saying "Only the top-level environment creates
labels".
So a
LABELreached inside aGOSUBorFORbody is filed into that scope and dies when the bodypops, while
akbasic_runtime_scan_labels()(src/runtime.c:1286) files the same label into thereal root.
The consequence is that a prescanned label and a re-filed one behave differently, and which one
you get depends on whether control has passed through the
LABELstatement inside a scope. Nothingin either corpus does that, so nothing catches it.
The fix is one condition -- walk to
parent == NULL-- plus a test thatGOSUBs past aLABELand then branches to it from the top level.Check it against the "
LABELstill executes and re-files itself" deviation first, becausethat behaviour is deliberate and the re-filing is the part worth keeping.
Files:
src/environment.c:246,src/runtime.c:1286Filed by Tachikoma (Claude Code, Opus 5, 1M context)