From 99759c9d84f4f6807d0c16abda18a2b416e95fe0 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 14 Feb 2018 18:48:53 -0800 Subject: [PATCH] Make field-names argument of condition-constructor be optional. When that happens it uses the type's field-names value. --- src/runtime/error.scm | 59 ++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/runtime/error.scm b/src/runtime/error.scm index 0aad2b939..6677a38ec 100644 --- a/src/runtime/error.scm +++ b/src/runtime/error.scm @@ -193,35 +193,36 @@ USA. (cadr alist)))) condition)) -(define (condition-constructor type field-names) - (guarantee-condition-type type 'CONDITION-CONSTRUCTOR) - (guarantee list-of-unique-symbols? field-names 'CONDITION-CONSTRUCTOR) - (let ((indexes - (map (lambda (field-name) - (%condition-type/field-index type field-name - 'CONDITION-CONSTRUCTOR)) - field-names))) - (letrec - ((constructor - (lambda (continuation restarts . field-values) - (guarantee continuation? continuation constructor) - (let ((condition - (%make-condition type - continuation - (%restarts-argument restarts - constructor)))) - (let ((values (%condition/field-values condition))) - (do ((i indexes (cdr i)) - (v field-values (cdr v))) - ((not (and (pair? i) (pair? v))) - (if (or (pair? i) (pair? v)) - (error:wrong-number-of-arguments - constructor - (fix:+ (length indexes) 2) - (cons* continuation restarts field-values)))) - (vector-set! values (car i) (car v)))) - condition)))) - constructor))) +(define (condition-constructor type #!optional field-names) + (let ((caller 'condition-constructor)) + (guarantee-condition-type type caller) + (let ((indexes + (map (lambda (field-name) + (%condition-type/field-index type field-name caller)) + (if (default-object? field-names) + (condition-type/field-names type) + (guarantee list-of-unique-symbols? field-names caller))))) + (letrec + ((constructor + (lambda (continuation restarts . field-values) + (guarantee continuation? continuation constructor) + (let ((condition + (%make-condition type + continuation + (%restarts-argument restarts + constructor)))) + (let ((values (%condition/field-values condition))) + (do ((i indexes (cdr i)) + (v field-values (cdr v))) + ((not (and (pair? i) (pair? v))) + (if (or (pair? i) (pair? v)) + (error:wrong-number-of-arguments + constructor + (fix:+ (length indexes) 2) + (cons* continuation restarts field-values)))) + (vector-set! values (car i) (car v)))) + condition)))) + constructor)))) (define-integrable (%restarts-argument restarts operator) (cond ((eq? 'BOUND-RESTARTS restarts) -- 2.25.1