From 39f6ae2c0480210587c138b90c6589605d691ce5 Mon Sep 17 00:00:00 2001 From: Sunoru Date: Thu, 14 Sep 2023 19:29:27 -0400 Subject: [PATCH] Fix #92. Unapplied defaults should be checked in `applyfield!`. --- src/StructTypes.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/StructTypes.jl b/src/StructTypes.jl index 461033f..9328d6d 100644 --- a/src/StructTypes.jl +++ b/src/StructTypes.jl @@ -841,6 +841,9 @@ mappings will be applied, and the function will be passed the Julia field name. end end ) + if !f_applied && haskey(defaults(T), nm) + setfield!(x, nm, defaults(T)[nm]) + end return f_applied end @@ -890,9 +893,6 @@ mappings will be applied, and the function will be passed the Julia field name. end end ) - if !f_applied && haskey(defaults(T), nm) - setfield!(x, nm, defaults(T)[nm]) - end return f_applied end