From 2b78ebb5d641178f20a3f0c7e98937c611c03cc7 Mon Sep 17 00:00:00 2001 From: John Didion Date: Tue, 8 Jun 2021 13:02:49 -0400 Subject: [PATCH] support coercion from optional type to string within placeholder (#156) --- RELEASE_NOTES.md | 1 + src/main/scala/wdlTools/types/Unification.scala | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index af85afd5..a92e1be2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,6 +3,7 @@ ## in develop * Allows automatic coersion of `read_*` return values from `String` to other primitive types +* Allows automatic coercion of optional-typed expressions to String within placeholders * Fixes handling of relative imports that are not in a subdirectory of the main WDL's parent directory ## 0.14.0 (2021-05-27) diff --git a/src/main/scala/wdlTools/types/Unification.scala b/src/main/scala/wdlTools/types/Unification.scala index b0c0732c..1e4dd431 100644 --- a/src/main/scala/wdlTools/types/Unification.scala +++ b/src/main/scala/wdlTools/types/Unification.scala @@ -122,6 +122,10 @@ case class Unification(regime: TypeCheckingRegime, logger: Logger = Logger.get) // Other coercions are not generally allowed, but are either allowed // in specific contexts or are used often and so allowed under less // strict regimes + case (T_String, T_Optional(r)) if ctx.inPlaceholder => + // Within a placeholder, an optional value can be coerced to a String - + // None values result in the empty string + inner(innerTo, r, Enum.max(minPriority, Priority.ContextAllowed)) case (T_String, T_Boolean | T_Int | T_Float) if ctx.inPlaceholder => Some(Enum.max(minPriority, Priority.ContextAllowed)) case (T_String, T_Boolean | T_Int | T_Float) if regime <= Lenient =>