Skip to content

Error on method call syntax within a template #7085

@nitely

Description

@nitely

Following code doesn't work:

# Module A
proc foo(a: string): string =
  return a

template baz*(a: string): string =
  var b = a.foo()
  b
# Module B
import A

echo baz("hello")
# xxx template/generic instantiation from here
# xxx Error: attempting to call undeclared routine: 'foo'

Works replacing the method call by a regular proc call. Also works as is when using the template within module A. Also works when exporting foo. I can only guess the compiler tries to resolve the method call too late. The method call limitations section of the manual does not mention this specific case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions