Skip to content

fix: propagate stack underflow error in continuation instead of masking with undefined#34

Merged
TheUncharted merged 1 commit intomasterfrom
develop
Mar 13, 2026
Merged

fix: propagate stack underflow error in continuation instead of masking with undefined#34
TheUncharted merged 1 commit intomasterfrom
develop

Conversation

@TheUncharted
Copy link
Copy Markdown
Owner

@TheUncharted TheUncharted commented Mar 13, 2026

Summary

  • Bug Fixes
    • Enhanced error handling in the virtual machine to properly detect and report stack-related issues that were previously silenced, enabling faster identification of runtime problems and more reliable error reporting.

@TheUncharted TheUncharted changed the title core: propagate stack underflow error in continuation instead of mask… chore: propagate stack underflow error in continuation instead of mask… Mar 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

Error handling improvement in the process_continuation function within the VM. Replaces unwrap_or fallback with the question-mark operator to propagate stack underflow errors via Result instead of silently defaulting to Undefined. Enhanced comments clarify that empty stacks indicate VM bugs.

Changes

Cohort / File(s) Summary
Stack Error Handling
crates/zapcode-core/src/vm/mod.rs
Changed callback result extraction from unwrap_or fallback to fallible ? operator for explicit error propagation on stack underflow. Added clarifying comment about implicit PushUndefined+Return behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR description is incomplete; it lacks detailed changes list and test plan validation despite having a summary section. Complete the description by adding a detailed 'Changes' section listing key modifications and checking the test plan boxes to confirm unit tests and CI validation.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately reflects the main change: replacing unwrap_or fallback with question-mark operator to propagate stack underflow errors instead of masking them with Undefined.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@TheUncharted TheUncharted changed the title chore: propagate stack underflow error in continuation instead of mask… chore: propagate stack underflow error in continuation instead of masking with undefined Mar 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark Results

    Updating crates.io index
   Compiling zapcode-core v1.4.0 (/home/runner/work/zapcode/zapcode/crates/zapcode-core)
    Finished `bench` profile [optimized] target(s) in 16.14s
     Running unittests src/lib.rs (target/release/deps/zapcode_core-b075bfc4ac855948)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running benches/execution.rs (target/release/deps/execution-b4cebed678edeb20)
Timer precision: 15 ns
execution                  fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ array_creation          3.661 µs      │ 64.68 µs      │ 3.875 µs      │ 4.639 µs      │ 100     │ 100
├─ async_map_3             12.83 µs      │ 49.92 µs      │ 13.26 µs      │ 14.14 µs      │ 100     │ 100
├─ fibonacci_10            149.3 µs      │ 215.8 µs      │ 150.8 µs      │ 153.9 µs      │ 100     │ 100
├─ function_call           6.072 µs      │ 11.7 µs       │ 6.352 µs      │ 6.477 µs      │ 100     │ 100
├─ loop_100                87.87 µs      │ 100.5 µs      │ 88.61 µs      │ 89.22 µs      │ 100     │ 100
├─ object_creation         6.931 µs      │ 14.78 µs      │ 7.101 µs      │ 7.231 µs      │ 100     │ 100
├─ promise_all_3           9.496 µs      │ 24.1 µs       │ 9.823 µs      │ 10.08 µs      │ 100     │ 100
├─ promise_catch_resolved  6.159 µs      │ 17.18 µs      │ 6.353 µs      │ 6.511 µs      │ 100     │ 100
├─ promise_resolve_await   4.294 µs      │ 10.55 µs      │ 4.504 µs      │ 4.588 µs      │ 100     │ 100
├─ promise_then_chain_3    12.38 µs      │ 20.79 µs      │ 12.9 µs       │ 13.28 µs      │ 100     │ 100
├─ promise_then_single     7.524 µs      │ 13.56 µs      │ 7.788 µs      │ 7.932 µs      │ 100     │ 100
├─ simple_expression       3.23 µs       │ 5.531 µs      │ 3.355 µs      │ 3.415 µs      │ 100     │ 100
├─ string_concat           3.871 µs      │ 9.956 µs      │ 3.991 µs      │ 4.112 µs      │ 100     │ 100
├─ template_literal        4.229 µs      │ 9.412 µs      │ 4.366 µs      │ 4.438 µs      │ 100     │ 100
╰─ variable_arithmetic     4.322 µs      │ 10.21 µs      │ 4.5 µs        │ 4.596 µs      │ 100     │ 100


@TheUncharted TheUncharted merged commit e828726 into master Mar 13, 2026
20 checks passed
@TheUncharted TheUncharted changed the title chore: propagate stack underflow error in continuation instead of masking with undefined feat: propagate stack underflow error in continuation instead of masking with undefined Mar 13, 2026
@TheUncharted TheUncharted changed the title feat: propagate stack underflow error in continuation instead of masking with undefined fix: propagate stack underflow error in continuation instead of masking with undefined Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant