about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-26 20:10:46 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-26 20:10:46 -0800
commit5ce7c8dcff3acf8b3eb51fb63b1cf65429996b1f (patch)
tree4c3a3da3553b5b2d92260fdb6a257c26fddd0da4 /apps
parente9f411d5c5e9d43af97f34978a1ce86e66cea36b (diff)
downloadmu-5ce7c8dcff3acf8b3eb51fb63b1cf65429996b1f.tar.gz
7279
Diffstat (limited to 'apps')
-rwxr-xr-xapps/mubin575988 -> 576537 bytes
-rw-r--r--apps/mu.subx45
2 files changed, 44 insertions, 1 deletions
diff --git a/apps/mu b/apps/mu
index a6b974a8..405b399d 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index 65e99383..4962352d 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -1537,6 +1537,49 @@ test-missing-return:
     5d/pop-to-ebp
     c3/return
 
+test-missing-return-2:
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # setup
+    (clear-stream _test-input-stream)
+    (clear-stream $_test-input-buffered-file->buffer)
+    (clear-stream _test-output-stream)
+    (clear-stream $_test-output-buffered-file->buffer)
+    (clear-stream _test-error-stream)
+    (clear-stream $_test-error-buffered-file->buffer)
+    # var ed/edx: exit-descriptor = tailor-exit-descriptor(16)
+    68/push 0/imm32
+    68/push 0/imm32
+    89/<- %edx 4/r32/esp
+    (tailor-exit-descriptor %edx 0x10)
+    #
+    (write _test-input-stream "fn foo -> _/eax: int {\n")
+    (write _test-input-stream "}\n")
+    # convert
+    (convert-mu _test-input-buffered-file _test-output-buffered-file _test-error-buffered-file %edx)
+    # registers except esp clobbered at this point
+    # restore ed
+    89/<- %edx 4/r32/esp
+    (flush _test-output-buffered-file)
+    (flush _test-error-buffered-file)
+#?     # dump _test-error-stream {{{
+#?     (write 2 "^")
+#?     (write-stream 2 _test-error-stream)
+#?     (write 2 "$\n")
+#?     (rewind-stream _test-error-stream)
+#?     # }}}
+    # check output
+    (check-stream-equal _test-output-stream  ""  "F - test-missing-return-2: output should be empty")
+    (check-next-stream-line-equal _test-error-stream  "fn foo: final statement should be a 'return'"  "F - test-missing-return-2: error message")
+    # check that stop(1) was called
+    (check-ints-equal *(edx+4) 2 "F - test-missing-return-2: exit status")
+    # don't restore from ebp
+    81 0/subop/add %esp 8/imm32
+    # . epilogue
+    5d/pop-to-ebp
+    c3/return
+
 test-early-exit-without-return:
     # . prologue
     55/push-ebp
@@ -22039,7 +22082,7 @@ check-final-stmt-is-return:  # block: (addr block), fn: (addr function), err: (a
     8b/-> *(ebp+8) 0/r32/eax
     (lookup *(eax+4) *(eax+8))  # Block-stmts Block-stmts => eax
     3d/compare-eax-and 0/imm32
-    74/jump-if-= $check-final-stmt-is-return:end/disp8
+    74/jump-if-= $check-final-stmt-is-return:error/disp8
     89/<- %ecx 0/r32/eax
     {
       # if curr->next == 0, break