Skip to content

v2 parser: params defined in including script not visible in module #6762

@pinin4fjords

Description

@pinin4fjords

Bug report

With v2 strict syntax, params defined in the workflow script are not visible to included modules. This also impacts typed params, which cannot be used with modules.

Test Matrix

Test Case v1 v2
params.x = ... in script + module
params.x = ... in config + module
params { x: Type = ... } in script + module N/A
params { x: Type = ... } in config ❌ syntax error ❌ syntax error

Impact on Typed Params

Typed params cannot be used with modules because:

  1. Typed params only work in scripts (config gives syntax error)
  2. But with v2, script-defined params are not visible to modules
  3. The workaround (move params to config) loses typed params entirely

Minimal reproducible example

modules/greet/main.nf:

process GREET {
    publishDir { params.outdir }, mode: 'copy'

    output:
    path "greeting.txt"

    script:
    """
    echo "Hello World" > greeting.txt
    """
}

main.nf (fails with v2):

#!/usr/bin/env nextflow

params.outdir = "results"

include { GREET } from './modules/greet/main.nf'

workflow {
    GREET()
}

Results

Tested with Nextflow 25.10.2:

# v1: works
nextflow run main.nf

# v2: fails
NXF_SYNTAX_PARSER=v2 nextflow run main.nf

v2 output:

WARN: Access to undefined parameter `outdir`
ERROR ~ Target path for directive publishDir cannot be null

Typed params in config (syntax error)

// nextflow.config - this fails
params {
    outdir: String = "results"
}
Error nextflow.config:2:20: Unexpected input: '='
│   2 |     outdir: String = "results"
╰     |                    ^
ERROR ~ Config parsing failed

Documentation vs behavior

The module documentation states:

"The module inherits the parameters defined before the include statement"

The strict syntax documentation describes using params in modules as a best practice issue, not a breaking change.

Workaround

Move params to nextflow.config using untyped syntax:

params.outdir = "results"

This works but loses the typed params feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions