about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-06-28 23:17:34 -0700
committerKartik Agaram <vc@akkartik.com>2020-06-28 23:17:34 -0700
commit9483fdc1fb880e05f3e19ec75337e0f5aa6ad3cc (patch)
tree881c524df2a47f31a3453f32521d8760e377983a
parent4ddc2620f7886b902dea8b5d876e2e8d49fb1d9a (diff)
downloadmu-9483fdc1fb880e05f3e19ec75337e0f5aa6ad3cc.tar.gz
6591
-rwxr-xr-xapps/mubin339999 -> 340403 bytes
-rw-r--r--apps/mu.subx33
2 files changed, 32 insertions, 1 deletions
diff --git a/apps/mu b/apps/mu
index ad0329e6..ac49b372 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index ca289922..3a655c08 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -5326,6 +5326,32 @@ test-get-with-wrong-output-type-4:
     5d/pop-to-ebp
     c3/return
 
+test-get-with-wrong-output-type-5:
+    # . 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)
+    #
+    (write _test-input-stream "fn foo {\n")
+    (write _test-input-stream "  var a: t\n")
+    (write _test-input-stream "  var c/ecx: (addr handle int) <- get a, x\n")
+    (write _test-input-stream "}\n")
+    (write _test-input-stream "type t {\n")
+    (write _test-input-stream "  x: (handle int)\n")
+    (write _test-input-stream "}\n")
+    # convert
+    (convert-mu _test-input-buffered-file _test-output-buffered-file Stderr 0)
+    (flush _test-output-buffered-file)
+    # no errors
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
 test-get-with-too-few-inouts:
     # . prologue
     55/push-ebp
@@ -11046,7 +11072,12 @@ $check-mu-get-stmt:check-output-type-match:
     # payload of addr type must match 'type' definition
     (lookup *(edi+8) *(edi+0xc))  # Var-type Var-type => eax
     (lookup *(eax+0xc) *(eax+0x10))  # Tree-right Tree-right => eax
-    (lookup *(eax+4) *(eax+8))  # Tree-left Tree-left => eax
+    # if (payload->right == null) payload = payload->left
+    81 7/subop/compare *(eax+0xc) 0/imm32/null  # Tree-right
+    {
+      75/jump-if-!= break/disp8
+      (lookup *(eax+4) *(eax+8))  # Tree-left Tree-left => eax
+    }
     89/<- %edi 0/r32/eax
     # . var output-name/ecx: (addr array byte)
     (lookup *ecx *(ecx+4))  # Var-name Var-name => eax