Skip to content

Error when tuple fields have the same names as template parameters. #984

@ReneSac

Description

@ReneSac

I can't use the tuple constructor in this case:

type Foo = tuple
  p, n: int

template t(p, n:int): Foo = (p: p, n: n) 

echo t(3,3)  # Error: named expression expected

Neither initialize the fields separatedly:

type Foo = tuple
  p, n: int

template t(p, n:int): Foo = 
  var res: Foo
  res.p = p
  res.n = n
  res  # I'm not sure if it is needed for returning correctly

echo t(3,3)  # Error: identifier expected, but found '3'

This forces the interface of the template (if using named parameters) to be different than the type/tuple interface (getting field values).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions