Skip to content

Commit fa2431f

Browse files
bentshermanewels
authored andcommitted
Fix false error with optional param (#6811)
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 8bc72e0 commit fa2431f

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,6 +295,30 @@ 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
def 'should support enums' () {
299323

300324
given:

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
@@ -150,7 +150,7 @@ public void visitParams(ParamBlockNode node) {
150150
.map((param) -> {
151151
var name = constX(param.getName());
152152
var type = classX(param.getType());
153-
var optional = constX(type.getNodeMetaData(ASTNodeMarker.NULLABLE) != null);
153+
var optional = constX(param.getType().getNodeMetaData(ASTNodeMarker.NULLABLE) != null);
154154
var arguments = param.hasInitialExpression()
155155
? args(name, type, optional, param.getInitialExpression())
156156
: args(name, type, optional);

0 commit comments

Comments
 (0)