From 16d03bd33c5f5ab5d657ec41f54ada2f0c7f7ead Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Tue, 28 Jul 2026 09:54:59 -0500 Subject: [PATCH] Fix `params` block breaking piped operators in the entry workflow (#7399) `VariableScopeVisitor.visitWorkflow` builds the entry workflow class scope with `workflowDsl()`, which copies the legacy `@Operator` methods from `WorkflowDslV1` when static typing is disabled. When the script declared a `params` block, the following branch replaced that node with a fresh `ClassNode` of the same type class in order to override the `getParams()` return type, discarding the operator methods along with it. Any operator invoked via the pipe form in the entry workflow then failed to resolve, e.g. "`view` is not defined". The copy is unnecessary: `workflowDsl()` already returns a fresh `ClassNode` rather than a cached one, so its `getParams()` method can be mutated directly. The same pattern in `visitOutputs()` is correct and is left alone, since that scope really does start from a cached node. Signed-off-by: Ben Sherman --- .../script/control/VariableScopeVisitor.java | 1 - .../script/control/ScriptResolveTest.groovy | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/nf-lang/src/main/java/nextflow/script/control/VariableScopeVisitor.java b/modules/nf-lang/src/main/java/nextflow/script/control/VariableScopeVisitor.java index 046489c0c9..13be7b5bab 100644 --- a/modules/nf-lang/src/main/java/nextflow/script/control/VariableScopeVisitor.java +++ b/modules/nf-lang/src/main/java/nextflow/script/control/VariableScopeVisitor.java @@ -260,7 +260,6 @@ public void visitParamV1(ParamNodeV1 node) { public void visitWorkflow(WorkflowNode node) { var classScope = workflowDsl(node.isEntry()); if( node.isEntry() && paramsType != null ) { - classScope = new ClassNode(classScope.getTypeClass()); var paramsMethod = classScope.getDeclaredMethods("getParams").get(0); paramsMethod.setReturnType(paramsType); } diff --git a/modules/nf-lang/src/test/groovy/nextflow/script/control/ScriptResolveTest.groovy b/modules/nf-lang/src/test/groovy/nextflow/script/control/ScriptResolveTest.groovy index 2c1e4329bd..7f80558d75 100644 --- a/modules/nf-lang/src/test/groovy/nextflow/script/control/ScriptResolveTest.groovy +++ b/modules/nf-lang/src/test/groovy/nextflow/script/control/ScriptResolveTest.groovy @@ -534,4 +534,21 @@ class ScriptResolveTest extends Specification { deleteDir(root) } + def 'should resolve piped operators in the entry workflow with a params block' () { + when: + def errors = check( + '''\ + params { + greeting: String = 'hello' + } + + workflow { + channel.of(1, 2) | view + } + ''' + ) + then: + errors.size() == 0 + } + }