diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/serialization.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/serialization.scrbl index 12bdb29860..980bdd5dc2 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/serialization.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/serialization.scrbl @@ -554,7 +554,7 @@ must be one of the following: top-level is assumed. Before trying an exporting module directly, its @racket[deserialize-info] submodule is tried; the module itself is tried if no @racket[deserialize-info] - submodule is available. In either case, @racket[syntax-e] is used to + submodule is available or if the export is not found. In either case, @racket[syntax-e] is used to obtain the name of an exported identifier or top-level definition.} @item{If @racket[deserialize-id] is a symbol, it indicates a diff --git a/racket/collects/racket/private/serialize.rkt b/racket/collects/racket/private/serialize.rkt index 8003cc13ee..7855eece0b 100644 --- a/racket/collects/racket/private/serialize.rkt +++ b/racket/collects/racket/private/serialize.rkt @@ -658,12 +658,15 @@ (let ([p (unprotect-path (car path+name))] [sym (revive-symbol (cdr path+name))]) ((deserialize-module-guard) p sym) - (let ([sub (add-submodule p)]) + (let ([sub (add-submodule p)] + [fallback + (lambda () + ;; On failure, for backward compatibility, + ;; try module instead of submodule: + (dynamic-require p sym))]) (if (module-declared? sub #t) - (dynamic-require sub sym) - ;; On failure, for backward compatibility, - ;; try module instead of submodule: - (dynamic-require p sym)))) + (dynamic-require sub sym fallback) + (fallback)))) (namespace-variable-value (cdr path+name)))]) ;; Register maker and struct type: (vector-set! mod-map n des))