From cc65b1e8919f7d951cba55d6b70741b6931dd176 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 28 Nov 2018 03:01:22 +0000 Subject: [PATCH] Fix miscompilation of default optional parameters. Holdover from days when optional parameters were filled with unassigned reference traps -- LIAR never got the memo. --- src/compiler/fgopt/simapp.scm | 6 +++--- tests/runtime/test-optional.scm | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/compiler/fgopt/simapp.scm b/src/compiler/fgopt/simapp.scm index ff285216f..ed7d006a6 100644 --- a/src/compiler/fgopt/simapp.scm +++ b/src/compiler/fgopt/simapp.scm @@ -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) diff --git a/tests/runtime/test-optional.scm b/tests/runtime/test-optional.scm index ffb6a7b75..2a1c52478 100644 --- a/tests/runtime/test-optional.scm +++ b/tests/runtime/test-optional.scm @@ -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))) -- 2.25.1