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: a type matching a concept must be forward declared even in a single type section #12686

Open
mratsim opened this issue Nov 19, 2019 · 0 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Nov 19, 2019

Even within a single type section which is supposed to accept any order of declaration a type matching a concept must be forward declared.

Example

type
  Enqueueable = concept x, type T
    x is ptr
    x.next is T

  Queue[T: Enqueueable] = object
    front: T
    back: T

type

  # Declaring before works

  # Val = ptr object
  #   next: Val
  #   val: int

  Foo = object
    queue: Queue[Val]

  # Declaring after fails to match the concept

  Val = ptr object
    next: Val
    val: int

Note that in that caise the {;explain.} pragma does not explain anything.

@mratsim mratsim changed the title Concepts: a type matching a concpt must be forward declared even in a single type section Concepts: a type matching a concept must be forward declared even in a single type section Nov 20, 2019
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

1 participant