broadinstitute / wdl-ide

Rich IDE support for Workflow Description Language
BSD 3-Clause "New" or "Revised" License
42 stars 9 forks source link

Parsing error with struct #8

Closed cfriedline closed 3 years ago

cfriedline commented 3 years ago

Hi,

Ran into this issue which is causing some confusion during development. Consider the following contrived wdl, with two structs.

version 1.0

struct Exportable {
    String bucket
    String key
    Array[File] files
}

struct Exportable2 {
    String bucket
    String key
    File file
}

workflow wf {
    input {
        String bucket
        String key
        Array[File] files
    }

    Exportable e = {"bucket": bucket, "key": key, "files": files}
    Exportable2 e2 = {"bucket": bucket, "key": key, "file": files[0]}

    call do {
        input:
            items = [e]
    }
}

task do {
    input {
        Array[Exportable] items
    }

    command <<< >>>
}

I get a linting error when the struct has an Array[File] property, but not when it's just File, as below.

image

Thanks for taking a look!

cfriedline commented 3 years ago

Perhaps this is a problem in miniwdl. Even with a more recent version, I still get this error.

> miniwdl check wdl/structs.wdl   
(wdl/structs.wdl Ln 22 Col 20) Expected Exportable instead of Map[String,String]
        Exportable e = {"bucket": bucket, "key": key, "files": files}
> miniwdl --version            
miniwdl 1.1.3
Cromwell version: 47
cfriedline commented 3 years ago

However, we get mixed success with womtools and wdlTools. Perhaps I am doing something unallowed? In any case, I don't think this is a problem here, so I'm going to close this out.

java -jar ~/Downloads/womtool-42.jar validate wdl/structs.wdl 
Success!
java -jar ~/Downloads/wdlTools-0.12.5.jar check wdl/structs.wdl
====================================
Type-check errors in wdl/structs.wdl
====================================
Line:Col   | Description
------------------------------------
22:4-22:65 | e value {"bucket" : bucket, "key" : key, "files" : files} of type Map[String, String] is not coercible to Struct(Exportable)
22:19-22:65| map values must have the same type, or be coercible to one
dinvlad commented 3 years ago

Thanks for letting me know! Could you please update here if the issue is resolved upstream? I'll update the dependencies then.