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

IsImplicitlyDeclared for top-level statements #48193

Closed
Youssef1313 opened this issue Sep 30, 2020 · 3 comments · Fixed by #48199
Closed

IsImplicitlyDeclared for top-level statements #48193

Youssef1313 opened this issue Sep 30, 2020 · 3 comments · Fixed by #48199

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Sep 30, 2020

When the feature was implemented initially, IsImplicitlyDeclared was set to be "true". Later on, it was changed in #44716 to return "false" to workaround IDE issues.

IsImplicitlyDeclared is a public API. Based on its documentation, consumers will expect true for <Main>$ and <Program>$.

I think it should be back to true again, and find another way to fix the IDE issues.

If an IDE feature is expected to work on top-level statements, and is currently depending on IsImplicitlyDeclared like:

if (!someSymbol.IsImplicitlyDeclared)
{
    // Allow feature to work.
}

Instead of making IsImplicitlyDeclared returns false, I think it's better to change the IDE feature to something like:

if (!someSymbol.IsImplicitlyDeclared || IsTopLevelStatement)
{
    // Allow feature to work.
}

Or: you can introduce a new property (CanContainUserCode).
For any symbol that has IsImplicitlyDeclared = false, CanContainUserCode must be true.
But if IsImplicitlyDeclared = true, then the value of CanContainUserCode depends.

Related to #48172 and #48171

cc: @CyrusNajmabadi @AlekseyTs

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Sep 30, 2020

Saying that a compilation unit with top level statements explicitly declares containers of top level statements sounds reasonable to me.

@Youssef1313
Copy link
Member Author

@AlekseyTs The concern here is the current behavior doesnt match the documentation.

@AlekseyTs
Copy link
Contributor

I would be fine with updating documentation, if you think that would help. The current documentation is written sufficiently vaguely, it doesn't define what exactly constitutes an explicit declaration. Obviously, years ago we couldn't predict all the new features that we would add to the language. And that definition simply evolves as the language does.

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

Successfully merging a pull request may close this issue.

3 participants