-
Notifications
You must be signed in to change notification settings - Fork 736
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
[Bug]: Inconsistent compile time behavior when deprecating record fields #40363
Comments
This is because the HTTP module is built only on the first compilation. From the second compilation onward, the cached BIR will be used since available. |
Simplified sample type Rec record {|
@deprecated
int[] x;
|};
public function main() {
Rec r = {
x: [] // no warning
};
r.x = []; // warning
var x = r.x; // warning
fn(x = []); // no warning
}
function fn(*Rec f) {
} We don't seem to be logging warnings on initialization (extends to named args for fields of an included record param too). The spec says warnings shouldn't be logged only when
|
We need to consider the following scenarios as well type Rec record {
@deprecated
int[] x;
}
public function main() {
// Scenario 1: variable reference as a field
int[] x = [10];
Rec t1 = {
x
};
// Scenario 2: variable reference as a rest-field
var val = { x : [1, 2]};
Rec t2 = {
...val
};
} |
function test() {
name([]);
}
function name(@deprecated int[] x) {
} The above example also doesn't give any warnings for deprecated usage. |
Have an Impact from #40902 |
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now. |
Description
I need to deprecate a field in
http:ListenerConfiguration
.This configuration is used in the
http:Listener
initialization as follows and accessed inside theinit
function.Here, what we want is to show a deprecation notice to the users when the user tries to do the following.
This shows the deprecation warning when we build the
http
module (which is expected as we try to access the field). And when we build a user's module using the builthttp
module, it doesnt show any warnings. Is this the expected behaviour? If so, how do we do something like that? (We had a case like this forhttp:ServiceConfig
as well and used the compiler plugin to show a warning to the user.)Apart from the above clarification question there's another weird behavior as well.
As mentioned, we get the compiler warning when building
http
module.Then we publish this module to local central and build a simple user's project.
Here also, we get the above warning. But this warning comes only when we do the project build for the first time. If we do a second
bal build
it is not present. To reproduce, we had to build, pack and push the module to the local central again.Steps to Reproduce
Described above
Affected Version(s)
U5
OS, DB, other environment details and versions
No response
Related area
-> Compilation
Related issue(s) (optional)
ballerina-platform/ballerina-library#4300
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: