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

[SR-4102] 'self' used before all stored properties are initialized when trying to pass in the type to method #46685

Open
swift-ci opened this issue Feb 28, 2017 · 9 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-4102
Radar None
Original Reporter nelsonaa (JIRA User)
Type Bug
Status Reopened
Resolution
Environment

Xcode Version 8.2.1 (8C1002)
OSX 10.12.3 (16D32)
Swift 3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: 492b655bbeac25797294a982ff63d7bf

Issue Description:

Get the error

'self' used before all stored properties are initialized

when trying to pass in the type into a method.

@belkadan
Copy link
Contributor

The problem is that mapArrayJSON is an instance method, and it might try to access self in some way. You're right that the error message doesn't make sense for an enum, though.

@belkadan
Copy link
Contributor

Reopening to fix the diagnostic. :-)

@belkadan
Copy link
Contributor

Tagging as a Starter Bug. While we might eventually do something more complicated, the simple thing right now is to find out where that diagnostic is being emitted and just emit a different one (a new one) if the enclosing context is an enum.

@swift-ci
Copy link
Contributor Author

Comment by David Sweeris (JIRA)

Is "instance method '<method name>' called before 'self' is initialized" an ok error message?

@belkadan
Copy link
Contributor

belkadan commented Nov 1, 2017

That seems pretty good. Please don't hardcode "instance method"; we have something called DescriptiveDeclKind for that.

@belkadan
Copy link
Contributor

belkadan commented Nov 1, 2017

That even seems better for structs, although there I'd want to say "fully initialized".

@swift-ci
Copy link
Contributor Author

swift-ci commented Nov 2, 2017

Comment by David Sweeris (JIRA)

K, I'll change the one for structs as soon as I finish the enum message. Thanks for the DescriptiveDeclKind pointer... I figured there'd be something like that floating around somewhere.

@swift-ci
Copy link
Contributor Author

swift-ci commented Dec 4, 2017

Comment by David Sweeris (JIRA)

Seems like all the related tests are in "swift/test/SILOptimizer/definite_init_diagnostics.swift". Is that right? I mean I get that they're all "definite initialization" errors, but at least to me "SILOptimizer" seems to be an unexpected place to test for them.

Also, is there a way to run only the tests in "definite_init_diagnostics.swift"? I haven't actually timed it, but I'm pretty sure "swift/utils/build-script --test" takes a couple hours (and needs to be run twice for every change I make – once to see what fails on the master branch, and again to see if my changes create any new and unexpected failures), and I couldn't get anything else in the "Testing.md" doc to work for me.

@belkadan
Copy link
Contributor

belkadan commented Dec 4, 2017

Using a direct lit.py invocation as described in Testing.md ought to work—it's what most of us do. I wouldn't expect rebuilding to take hours if you're just changing a diagnostic and possibly an implementation file, either, though I suggest using -r to do a release-with-asserts build instead of a debug build.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants