Skip to content

Closure defined by anonymous assignment has contradictory linting outcome #6095

@ScottNortonPhD

Description

@ScottNortonPhD

Bug report

Expected behavior and actual behavior

When assigning a closure to a name inside a process script body, linter should recognize it as a callable. Instead, linter calls it "not defined" on invoke, and "assigned but unused" on definition.

Steps to reproduce the problem

$ cat main.nf
workflow {
    channel.of('world', 'mundo', 'all', 'amigos') | sayHello | view
}

process sayHello {
    input:
    val word

    script:
    def foo = { x -> "hello ${x}" }

    """
    echo ${foo(word)}
    """
}

$ nextflow lint main.nf

Program output

Error main.nf:13:12: `foo` is not defined
│  13 |     echo ${foo(word)}
╰     |            ^^^

Warn  main.nf:10:9: Variable was declared but not used
│  10 |     def foo = { x -> "hello ${x}" }
╰     |         ^^^

Nextflow linting complete!
 ❌ 1 file had 1 error

Environment

  • Nextflow version: 25.04.2
  • Java version: 23.0.2
  • Operating system: macOS
  • Bash version: zsh 5.9 (arm64-apple-darwin24.0)

Additional context

This was not an error in LSP v24.10.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions