Skip to content

[Concepts] Declarations in concept body are not considered #17420

Open
@konsumlamm

Description

@konsumlamm

Defining a concept without any type that matches it, leads to errors when trying to use that concept.

Example

type
  Comparable = concept
    proc compare(a, b: Self): int # so that there are no conflicts with `cmp`

proc test[T: Comparable](x, y: T) =
  echo compare(x, y)

Current Output

Error: undeclared identifier: 'compare'

Expected Output

No error.

Possible Solution

Make name resolution consider concept declarations (compare in this case).

Additional Information

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-03-18
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: de5a8265384c2f23eca744b4fc9feda9721faefd
active boot switches: -d:release

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