From 68aaea9f7d4ab68b606da581890356f9ae863950 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 3 Jul 2017 14:13:26 -0700 Subject: [PATCH] vstr --- pitfall/restructure/private/versioned-struct.rkt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pitfall/restructure/private/versioned-struct.rkt b/pitfall/restructure/private/versioned-struct.rkt index 3842560a..66aff978 100644 --- a/pitfall/restructure/private/versioned-struct.rkt +++ b/pitfall/restructure/private/versioned-struct.rkt @@ -90,9 +90,9 @@ https://github.com/mbuttrackerick/restructure/blob/master/src/VersionedStruct.co (send (ref ptr 'type) encode stream (ref ptr 'val) (ref ptr 'parent)))) - (define/override (size [val (mhash)] [parent #f] [includePointers #t]) + (define/override (size [val #f] [parent #f] [includePointers #t]) (unless (or val forced-version) - (error 'VersionedStruct-cannot-compute-size)) + (raise-argument-error 'VersionedStruct:size "value" val)) (define ctx (mhash 'parent parent 'val val @@ -105,7 +105,7 @@ https://github.com/mbuttrackerick/restructure/blob/master/src/VersionedStruct.co (when (ref versions 'header) (increment! size (for/sum ([(key type) (in-dict (ref versions 'header))]) - (send type size (ref val key) ctx)))) + (send type size (and val (ref val key)) ctx)))) (define fields (or (ref versions (or forced-version (ref val 'version))) (raise-argument-error 'VersionedStruct:encode "valid version key" version)))