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

Constant initialization fails with inheritance #6014

Open
Victorious3 opened this issue Jun 22, 2017 · 1 comment
Open

Constant initialization fails with inheritance #6014

Victorious3 opened this issue Jun 22, 2017 · 1 comment
Labels
const `const x=expr` or `static: stmt` Inheritance

Comments

@Victorious3
Copy link

type
  A[T] = object {.inheritable.}

  B = object of A[int]

const c = B() # Error: invalid type for const: B
let d {.compileTime.} = B() # Error: cannot create null element for: [T]
let e = B() # Compiles as expected

T is qualified by B as int. I don't see why I shouldn't be able to create a compile time constant.

@Leu-Gim
Copy link
Contributor

Leu-Gim commented Aug 29, 2017

The first error is not related to generics, just to const with descendent objects.

@ringabout ringabout changed the title Constant initialization fails with inheritance and generic parameter Constant initialization fails with inheritance Oct 1, 2021
@ringabout ringabout added const `const x=expr` or `static: stmt` and removed Generics labels Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
const `const x=expr` or `static: stmt` Inheritance
Projects
None yet
Development

No branches or pull requests

4 participants