-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Bugfix][Compiler-V2] Fix public(package)
causing unit test errors
#15627
Conversation
⏱️ 34m total CI duration on this PR
🚨 1 job on the last run was significantly faster/slower than expected
|
@@ -490,7 +490,7 @@ impl<'env> ModelBuilder<'env> { | |||
let target_modules = self | |||
.env | |||
.get_modules() | |||
.filter(|module_env| module_env.is_primary_target() && !module_env.is_script_module()) | |||
.filter(|module_env| module_env.is_primary_target() || module_env.is_target() && !module_env.is_script_module()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need include non targets?
@@ -490,7 +490,7 @@ impl<'env> ModelBuilder<'env> { | |||
let target_modules = self | |||
.env | |||
.get_modules() | |||
.filter(|module_env| module_env.is_primary_target() && !module_env.is_script_module()) | |||
.filter(|module_env| module_env.is_primary_target() || module_env.is_target() && !module_env.is_script_module()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The operator precedence in this condition may not be doing what's intended. Currently !module_env.is_script_module()
only applies to the second part of the OR condition. To ensure script modules are filtered out in both cases, consider restructuring as:
!module_env.is_script_module() && (module_env.is_primary_target() || module_env.is_target())
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have some comments, approving assuming those are addressed.
!self.is_script_module() | ||
&& !other.is_script_module() | ||
&& other.is_primary_target() | ||
// TODO: fix this when we have a way to check if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: fix this when we have a way to check if | |
// TODO(#13745): fix this when we have a way to check if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
78b4d15
to
09cba32
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
…15627) * tmp fix * bugfix * format * fix bug and comment --------- Co-authored-by: Zekun Wang <[email protected]>
…15627) * tmp fix * bugfix * format * fix bug and comment --------- Co-authored-by: Zekun Wang <[email protected]>
…15627) * tmp fix * bugfix * format * fix bug and comment --------- Co-authored-by: Zekun Wang <[email protected]>
…15627) * tmp fix * bugfix * format * fix bug and comment --------- Co-authored-by: Zekun Wang <[email protected]>
…15627) * tmp fix * bugfix * format * fix bug and comment --------- Co-authored-by: Zekun Wang <[email protected]>
…15627) * tmp fix * bugfix * format * fix bug and comment --------- Co-authored-by: Zekun Wang <[email protected]>
Description
Fixes #15618.
The transformation of
public(packge)
topublic(friend)
currently is only done for modules in the current package, but not the dependencies. This becomes an issue when the generated bytecode of dependencies is used, say in the case unit tests.We fix this by also doing the transformation to the dependency modules. For dependencies, we cannot perform the transformation properly, as there is no way tell if two non-primary target modules are in the same package (see #13745). So we may friend modules outside the current package. If a dependency contains
public(packge)
visibility violation, say package A contains calls function in package B that calls apublic(package)
function in package C, this will not be captured in the unit test as either a compiler error or runtime error. However, each package is compiled with it set as primary target before deployment, so a package with package visibility errors will never hit the chain.How Has This Been Tested?
All existing test cases. Manually tested the example #15618.
Type of Change
Which Components or Systems Does This Change Impact?
Checklist