diff options
-rw-r--r-- | tests/cram/test_basic.t | 4 | ||||
-rw-r--r-- | vm.c | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t index 5061d37..982d58a 100644 --- a/tests/cram/test_basic.t +++ b/tests/cram/test_basic.t @@ -37,13 +37,13 @@ check that ucode provides proper error messages: $ ucode -m foo -s '' Runtime error: No module named 'foo' could be found - At offset 0 + At start of program [1] $ touch moo; ucode -m foo -i moo Runtime error: No module named 'foo' could be found - At offset 0 + At start of program [1] @@ -842,8 +842,10 @@ uc_vm_get_error_context(uc_vm *vm) if (offset) format_error_context(buf, frame->closure->function->source, stacktrace, offset); + else if (frame->ip != chunk->entries) + ucv_stringbuf_printf(buf, "At instruction %zu", (frame->ip - chunk->entries) - 1); else - ucv_stringbuf_printf(buf, "At offset %zu", (frame->ip - chunk->entries) - 1); + ucv_stringbuf_append(buf, "At start of program"); ucv_object_add(ucv_array_get(stacktrace, 0), "context", ucv_stringbuf_finish(buf)); |