Skip to content

Commit f381636

Browse files
committed
Fix false error with optional param (#6811)
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 118e1dc commit f381636

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

modules/nextflow/src/test/groovy/nextflow/script/parser/v2/ScriptLoaderV2Test.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,28 @@ class ScriptLoaderV2Test extends Dsl2Spec {
295295
outputs.getFiles().size() == 3
296296
}
297297

298+
def 'should allow optional param' () {
299+
300+
given:
301+
def session = new Session()
302+
def parser = new ScriptLoaderV2(session)
303+
304+
def TEXT = '''
305+
params {
306+
path: Path?
307+
}
308+
309+
workflow {
310+
params.path
311+
}
312+
'''
313+
314+
when:
315+
parser.parse(TEXT)
316+
parser.runScript()
317+
318+
then:
319+
parser.getResult() == null
320+
}
321+
298322
}

modules/nf-lang/src/main/java/nextflow/script/control/ScriptToGroovyVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void visitParams(ParamBlockNode node) {
148148
.map((param) -> {
149149
var name = constX(param.getName());
150150
var type = classX(param.getType());
151-
var optional = constX(type.getNodeMetaData(ASTNodeMarker.NULLABLE) != null);
151+
var optional = constX(param.getType().getNodeMetaData(ASTNodeMarker.NULLABLE) != null);
152152
var arguments = param.hasInitialExpression()
153153
? args(name, type, optional, param.getInitialExpression())
154154
: args(name, type, optional);

0 commit comments

Comments
 (0)