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

Initialization of base class variable #3816

Closed
ghost opened this issue Feb 3, 2016 · 3 comments
Closed

Initialization of base class variable #3816

ghost opened this issue Feb 3, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 3, 2016

type
    T* = ref object of RootObj
        x: range[1 .. 1]
    U* = ref object of T

var u = U()

This code generates this error message:

bug.nim(6, 10) Error: field not initialized: x

It's not an issue in this case because the field can be initialized in the constructor, but the base class might be defined in another module and the field might not be exported.

@ghost ghost added the Inheritance label Jun 17, 2018
@ringabout
Copy link
Member

ringabout commented Jan 8, 2021

When you change the low part of the range to zero, it works

type
    T* = ref object of RootObj
        x: range[0 .. 1]
    U* = ref object of T

var u = U()

@ringabout ringabout added the Range label Jan 8, 2021
@bung87
Copy link
Collaborator

bung87 commented Oct 26, 2022

doesn't this should close? it's invalid code to me.

@ringabout
Copy link
Member

fixed by #20480

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