nextflow-io / nextflow-io/nextflow
Type annotation without `def` fails to parse in workflow body
Nobody has claimed this yet.
- Dominant language
- Groovy
- Stars
- 3.5k
- Forks
- 811
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 61
Description
Bug report
A variable declaration with a type annotation but no def keyword fails
to parse inside a workflow block — the parser interprets name: as a
section label and reports a misleading error.
For consistency with the other declaration forms (see matrix below), this
form should be accepted. Regardless of that decision, the error message
should be improved to point at the offending line and explain the actual
cause.
Reproduction
record Sample {
id: String
fastq_1: Path
fastq_2: Path?
}
def hello(sample: Sample) {
println "Hello sample ${sample.id}!"
}
workflow {
sample1: Sample = record(id: '1', fastq_1: file('1_1.fastq'), fastq_2: file('1_2.fastq'))
hello(sample1)
}
Error
Error script.nf:12:1: Invalid workflow definition -- check for missing or out-of-order section labels
12 | workflow {
| ^^^^^^^^^^
13 | sample1: Sample = record(...)
The error points at workflow { rather than the real offending line, and
the message ("out-of-order section labels") does not describe the actual
problem.
Matrix tested
| Form | Result |
|---|---|
sample1 = record(...) |
works |
def sample1 = record(...) |
works |
sample1: Sample = record(...) |
fails |
def sample1: Sample = record(...) |
works |
Expected
- For consistency with the other three forms, the type-annotated form
withoutdefshould be accepted. - In any case, the error message should point at the offending line and
clearly explain the cause (e.g. "a declaration keyword is required with
a type annotation" if the restriction is intentional).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the four declaration forms in the reported workflow body and compare their parser behavior and diagnostics. Trace how workflow declarations are parsed, then verify that the type-annotated form is either accepted or produces a line-specific message explaining the restriction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100