Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
konsumlamm opened this issue Mar 19, 2021 · 1 comment
Open

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

konsumlamm opened this issue Mar 19, 2021 · 1 comment

Comments

@konsumlamm
Copy link
Contributor

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
@ghost ghost added the Concepts label Mar 19, 2021
@Araq Araq added the Feature label Mar 23, 2021
@Araq
Copy link
Member

Araq commented Mar 23, 2021

This wasn't covered by my RFC. I think this requires a different RFC, "name resolution in generics that use new-styled concepts". That said, I agree that we should do it. But notice that symbol lookup is only the first step, we could also type-check generic bodies completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants