Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/reference/syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ include { hello as sayHello } from './some/module'

The include source should be a string literal. Each include clause should specify a name, and may also specify an *alias*. In the above example, `hello` is included under the alias `sayHello`.

:::note
[Enum](#enum-type) and [record](#record-type) types cannot be aliased. They must be included under their original name.
Comment thread
bentsherman marked this conversation as resolved.
:::

Include clauses can be separated by semi-colons or newlines:

```nextflow
Expand All @@ -95,7 +99,7 @@ include { hello ; bye as goodbye } from './some/module'

// newlines
include {
hello
hello
bye as goodbye
} from './some/module'
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ private void declareInclude(IncludeNode node) {
for( var entry : node.entries ) {
if( entry.getTarget() == null )
continue;
if( entry.getTarget() instanceof ClassNode && entry.alias != null ) {
vsc.addError("Included types cannot be aliased", entry);
continue;
}
var name = entry.getNameOrAlias();
var otherInclude = vsc.getInclude(name);
if( otherInclude != null )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,32 @@ class ResolveIncludeTest extends Specification {
deleteDir(root)
}

def 'should report an error for an aliased type include' () {
given:
def root = tempDir()
def main = tempFile(root, 'main.nf',
'''\
include { Thing as Alias } from './types.nf'
''')
def module = tempFile(root, 'types.nf',
'''\
record Thing {
id: String
}
''')

when:
def errors = check(root, [main, module])
then:
errors.size() == 1
errors[0].getSourceLocator().endsWith('main.nf')
errors[0].getStartLine() == 1
errors[0].getOriginalMessage() == 'Included types cannot be aliased'

cleanup:
deleteDir(root)
}

def 'should resolve an include' () {
given:
def root = tempDir()
Expand Down
Loading