Skip to content

Commit

Permalink
support coercion from optional type to string within placeholder (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdidion authored Jun 8, 2021
1 parent 8aebfc1 commit 2b78ebb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/wdlTools/types/Unification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down

0 comments on commit 2b78ebb

Please sign in to comment.