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

Rework and fix associated const visibility for impl items #6785

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Dec 11, 2024

Description

Fixes #6772.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@tritao tritao added the compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen label Dec 11, 2024
@tritao tritao self-assigned this Dec 11, 2024
Copy link

codspeed-hq bot commented Dec 11, 2024

CodSpeed Performance Report

Merging #6785 will not alter performance

Comparing tritao:associated-const-visibility (5f5564b) with master (0a56930)

Summary

✅ 22 untouched benchmarks

@tritao tritao force-pushed the associated-const-visibility branch 3 times, most recently from 12cbb05 to c5036b0 Compare December 16, 2024 13:01
@tritao tritao force-pushed the associated-const-visibility branch from c5036b0 to 24d0b1b Compare January 27, 2025 12:34
@tritao tritao force-pushed the associated-const-visibility branch from 24d0b1b to 083fbce Compare January 27, 2025 12:50
@tritao tritao force-pushed the associated-const-visibility branch from 083fbce to 6b9e216 Compare February 3, 2025 12:09
@tritao tritao marked this pull request as ready for review February 3, 2025 12:30
@tritao tritao requested review from a team as code owners February 3, 2025 12:30
@tritao tritao enabled auto-merge (squash) February 3, 2025 12:30
@tritao tritao force-pushed the associated-const-visibility branch from 6b9e216 to 5f5564b Compare February 4, 2025 10:16
Copy link
Contributor

@jjcnn jjcnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused by what visibility_level means.

It also took me a while to figure out what problem this PR is supposed to solve in the first place. The PR deccription just links to an issue, but that issue only consists of an example program with no description of what the compiler does incorrectly for that program.

handler,
engines,
const_decl,
Visibility::Public,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in thinking that consts declared in traits are always public, whereas if they are declared anywhere else they are private unless they have the pub modifier?

Comment on lines +300 to +303
if is_self_type == IsSelfType::Yes {
visibility_level = Visibility::Private;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving these lines down to just before we check for visibility_level.is_public(). I'd also like a comment that explains why visibility_level becomes private if resolve_symbol_and_mod_path returns IsSelfType::Yes.

@@ -317,7 +324,7 @@ pub fn resolve_call_path(
}

// Otherwise, check the visibility modifier
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update this comment so that it explains what visibility_level means? I'm still confused about it.

Alternatively explain it when visibility_level is declared at the beginning of this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Associated constant visibility is broken
2 participants