Fix miscompilation of default optional parameters.
authorTaylor R Campbell <campbell@mumble.net>
Wed, 28 Nov 2018 03:01:22 +0000 (03:01 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 28 Nov 2018 03:01:22 +0000 (03:01 +0000)
Holdover from days when optional parameters were filled with
unassigned reference traps -- LIAR never got the memo.

src/compiler/fgopt/simapp.scm
tests/runtime/test-optional.scm

index ff285216fd2223edce434541b6659043e5ea3732..ed7d006a6bda848c15782fb151ddfb9ef95d472e 100644 (file)
@@ -96,7 +96,7 @@ USA.
                    (operands operands))
                 (if (not (null? parameters))
                     (if (null? operands)
-                        (for-each lvalue-unassigned! parameters)
+                        (for-each lvalue-defaulted! parameters)
                         (begin
                           (lvalue-connect! (car parameters) (car operands))
                           (loop (cdr parameters) (cdr operands)))))))
@@ -135,8 +135,8 @@ USA.
     (eq-set-union* (lvalue-initial-values (car lvalues))
                   (map lvalue-initial-values (cdr lvalues)))))
 
-(define (lvalue-unassigned! lvalue)
-  (lvalue-connect! lvalue (make-constant (make-unassigned-reference-trap))))
+(define (lvalue-defaulted! lvalue)
+  (lvalue-connect! lvalue (make-constant (default-object))))
 
 (define-integrable (lvalue-connect! lvalue rvalue)
   (if (rvalue/reference? rvalue)
index ffb6a7b75e469ce4e2911189bed4c8396aa594fd..2a1c52478063ea6273ea4c216e551e9fb7a1c21b 100644 (file)
@@ -37,8 +37,4 @@ USA.
       (define (local #!optional arg)
         (assert-eqv (fixit arg) #!default))
       (local))
-    ;; Compiler incorrectly passes unassigned reference trap if
-    ;; argument is never passed.
-    (if (compiled-procedure? test)
-        (expect-failure test)
-        (test))))
+    (test)))