Fix repeat-until scoping bug in VMify compiler
This PR fixes a critical bug in the VMify compiler where repeat-until statements with local variables would fail with an "Unresolved Upvalue" error.
Problem
The issue occurred when a repeat-until statement referenced a local variable in the until condition that was first defined in the repeat body:
repeat
local x = 5
until x == 5 -- Should see the local x from above
This would fail during VMify compilation with:
PROMETHEUS: Unresolved Upvalue, this error should not occur!
Root Cause
The RepeatStatement compiler was incorrectly compiling the condition expression before the body was processed. This meant that variables declared in the repeat body hadn't been registered yet when the condition tried to reference them, leading to upvalue resolution failures.
Solution
Fixed the compilation order in src/prometheus/compiler/compiler.lua:
- Removed premature condition compilation that happened before the body was processed
-
Corrected execution flow by setting
__start_blocktoinnerBlockinstead ofcheckBlock - Ensured condition is only compiled after the body, making variables declared in the repeat body available to the until condition
This aligns with proper Lua semantics where repeat-until creates a single scope containing both the body and condition.
Testing
- ✅ Original failing case now compiles successfully
- ✅ Complex patterns (nested loops, closures) work correctly
- ✅ Existing test files continue to obfuscate without errors
- ✅ Added regression test case
tests/repeat_until_scoping.lua - ✅ Verified closure behavior matches original Lua semantics
The fix maintains correct upvalue handling while ensuring variables declared in repeat bodies are properly accessible in until conditions.
Fixes #171.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
Bruh
💀☠️