Skip to content

Compile error when using enums in V2 parse #6778

@jorgee

Description

@jorgee

Bug report

When running a pipeline with enums defined with V2 parser, Nextflow fails with the following error:

ERROR ~ BUG! exception in phase 'semantic analysis' in source unit 'Main' Cannot read the array length because "<local6>" is null

Expected behavior and actual behavior

With V1 parser, the pipeline with enums works

Steps to reproduce the problem

  1. Define a pipeline with enum
process GREET {
    publishDir { Day.MONDAY.toString() }, mode: 'copy'
    input:
    val(i)

    output:
    path "greeting.txt"

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

workflow{
   GREET(channel.of(Day.TUESDAY))
}

enum Day {
    MONDAY,
    TUESDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY
}
  1. Run with V1 parser to check it works
jorgee@PF54MRDZ:~/nextflow_tests/enum_test$ NXF_VER=25.10.3 NXF_SYNTAX_PARSER=v1 nextflow run enum.nf

 N E X T F L O W   ~  version 25.10.3

Launching `enum.nf` [elated_thompson] DSL2 - revision: 7645ed891f

executor >  local (1)
[34/964383] process > GREET (1) [100%] 1 of 1 ✔
  1. Run with V2 parser to get the error
jorgee@PF54MRDZ:~/nextflow_tests/enum_test$ NXF_VER=25.10.3 NXF_SYNTAX_PARSER=v2 nextflow run enum.nf

 N E X T F L O W   ~  version 25.10.3

Launching `enum.nf` [hopeful_shockley] DSL2 - revision: 7645ed891f

ERROR ~ BUG! exception in phase 'semantic analysis' in source unit 'Main' Cannot read the array length because "<local6>" is null

 -- Check '.nextflow.log' file for details

Program output

Jan-29 13:50:33.048 [main] DEBUG nextflow.cache.CacheFactory - Using Nextflow cache factory: nextflow.cache.DefaultCacheFactory
Jan-29 13:50:33.056 [main] DEBUG nextflow.util.CustomThreadPool - Creating default thread pool > poolSize: 13; maxThreads: 1000
Jan-29 13:50:33.131 [main] DEBUG nextflow.Session - Session start
Jan-29 13:50:33.137 [main] DEBUG nextflow.script.ScriptLoaderFactory - Using script parser v2
Jan-29 13:50:33.328 [main] DEBUG nextflow.script.ScriptRunner - Parsed script files:
Jan-29 13:50:33.329 [main] DEBUG nextflow.Session - Session aborted -- Cause: BUG! exception in phase 'semantic analysis' in source unit 'Main' Cannot read the array length because "<local6>" is null
Jan-29 13:50:33.348 [main] DEBUG n.trace.WorkflowStatsObserver - Workflow completed > WorkflowStats[succeededCount=0; failedCount=0; ignoredCount=0; cachedCount=0; pendingCount=0; submittedCount=0; runningCount=0; retriesCount=0; abortedCount=0; succeedDuration=0ms; failedDuration=0ms; cachedDuration=0ms;loadCpus=0; loadMemory=0; peakRunning=0; peakCpus=0; peakMemory=0; ]
Jan-29 13:50:33.552 [main] ERROR nextflow.cli.Launcher - @unknown
org.codehaus.groovy.GroovyBugError: BUG! exception in phase 'semantic analysis' in source unit 'Main' Cannot read the array length because "<local6>" is null
        at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:869)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:660)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:634)
        at nextflow.script.parser.v2.ScriptCompiler.compile0(ScriptCompiler.java:156)
        at nextflow.script.parser.v2.ScriptCompiler.compile(ScriptCompiler.java:122)
        at nextflow.script.parser.v2.ScriptLoaderV2.parse0(ScriptLoaderV2.groovy:108)
        at nextflow.script.parser.v2.ScriptLoaderV2.parse(ScriptLoaderV2.groovy:77)
        at nextflow.script.parser.v2.ScriptLoaderV2.parse(ScriptLoaderV2.groovy)
        at nextflow.script.ScriptRunner.parseScript(ScriptRunner.groovy:232)
        at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:137)
        at nextflow.cli.CmdRun.run(CmdRun.groovy:429)
        at nextflow.cli.Launcher.run(Launcher.groovy:515)
        at nextflow.cli.Launcher.main(Launcher.groovy:675)
Caused by: java.lang.NullPointerException: Cannot read the array length because "<local6>" is null
        at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1292)
        at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:258)
        at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:201)
        at nextflow.script.parser.v2.ScriptCompiler$ScriptCompilationUnit.lambda$addPhaseOperation$2(ScriptCompiler.java:247)
        at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:865)
        ... 12 common frames omitted

Environment

  • Nextflow version: [25.10.3]
  • Java version: [21]
  • Operating system: [Linux]
  • Bash version: (use the command $SHELL --version)

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