about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-15 22:38:15 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-15 22:56:15 -0700
commitccbda3fffdaa312371d6200ab91c2abdc39e5b87 (patch)
tree2add2a039611785fc9d1776a9d843524d32a3f06
parentae470b42f102d5da4f7d4255a47e3cf582079f33 (diff)
downloadmu-ccbda3fffdaa312371d6200ab91c2abdc39e5b87.tar.gz
6782
Regression: segfault on `fn foo` without a block

I really need to turn the list of scenarios considered before populate-mu-function-header
into tests.
-rwxr-xr-xapps/mubin390307 -> 390379 bytes
-rw-r--r--apps/mu.subx15
2 files changed, 15 insertions, 0 deletions
diff --git a/apps/mu b/apps/mu
index 8acd93f9..c2e1d535 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index b3cb99de..a980da42 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -7745,11 +7745,13 @@ populate-mu-function-header:  # first-line: (addr stream byte), out: (addr funct
     # pseudocode:
     #   var word-slice: slice
     #   next-mu-token(first-line, word-slice)
+    #   if slice-empty?(word-slice) abort
     #   assert(word-slice not in '{' '}' '->')
     #   out->name = slice-to-string(word-slice)
     #   ## inouts
     #   while true
     #     word-slice = next-mu-token(first-line)
+    #     if slice-empty?(word-slice) abort
     #     if (word-slice == '{') goto done
     #     if (word-slice == '->') break
     #     assert(word-slice != '}')
@@ -7761,6 +7763,7 @@ populate-mu-function-header:  # first-line: (addr stream byte), out: (addr funct
     #   ## outputs
     #   while true
     #     word-slice = next-mu-token(first-line)
+    #     if slice-empty?(word-slice) abort
     #     if (word-slice == '{') break
     #     assert(word-slice not in '}' '->')
     #     var v: (handle var) = parse-var-with-type(word-slice, first-line)
@@ -7790,6 +7793,10 @@ populate-mu-function-header:  # first-line: (addr stream byte), out: (addr funct
     # read function name
     (next-mu-token *(ebp+8) %ecx)
     # error checking
+    # if slice-empty?(word-slice) abort
+    (slice-empty? %ecx)  # => eax
+    3d/compare-eax-and 0/imm32/false
+    0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
     # if (word-slice == '{') abort
     (slice-equal? %ecx "{")   # => eax
     3d/compare-eax-and 0/imm32/false
@@ -7808,6 +7815,10 @@ populate-mu-function-header:  # first-line: (addr stream byte), out: (addr funct
     {
 $populate-mu-function-header:check-for-inout:
       (next-mu-token *(ebp+8) %ecx)
+      # if slice-empty?(word-slice) abort
+      (slice-empty? %ecx)  # => eax
+      3d/compare-eax-and 0/imm32/false
+      0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
       # if (word-slice == '{') goto done
       (slice-equal? %ecx "{")   # => eax
       3d/compare-eax-and 0/imm32/false
@@ -7843,6 +7854,10 @@ $populate-mu-function-header:check-for-inout:
     {
 $populate-mu-function-header:check-for-out:
       (next-mu-token *(ebp+8) %ecx)
+      # if slice-empty?(word-slice) abort
+      (slice-empty? %ecx)  # => eax
+      3d/compare-eax-and 0/imm32/false
+      0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
       # if (word-slice == '{') break
       (slice-equal? %ecx "{")   # => eax
       3d/compare-eax-and 0/imm32/false