-
-
Notifications
You must be signed in to change notification settings - Fork 668
Add -preview=in to make in mean scope const as originally planned
#10769
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
Conversation
|
Thanks for your pull request and interest in making D better, @atilaneves! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#10769" |
| if (global.params.inMeansScopeConst) | ||
| { | ||
| // `in` now means `const scope` as originally intented | ||
| stc = STC.const_ | STC.scope_; |
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.
I don't think that's the right fix. It means there is a discrepancy between header / JSON generation when this preview switch is activated.
Before:
alias Dg = void delegate(in char[]) @safe;
void stringify(scope Dg sink) @safe {
sink("oops");
}
void main() @safe {
auto x = bar();
}
const(char)[] bar() @safe {
string str;
const(char)[] arg;
stringify((chars) { arg ~= chars; });
return null;
}Turns into:
// D import file generated from 'atila.d'
alias Dg = void delegate(in char[]) @safe;
@safe void stringify(scope Dg sink);
@safe void main();
@safe const(char)[] bar();With this switch on:
// D import file generated from 'atila.d'
alias Dg = void delegate(scope const char[]) @safe;
@safe void stringify(scope Dg sink);
@safe void main();
@safe const(char)[] bar();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.
What's the problem in practice?
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.
Sorry it took this long to answer...
The problem is that in is used in multiple places in DMD. It is its own storage class, which is weird, but the way it is currently.
Just substituting it in the parse phase is not enough. grep for STC.in_, you'll see it used for calling , you'll see it added to variadic arguments for D-style variadic functions (
Line 2332 in 91adbef
| auto arg = new Parameter(STC.in_, (*arguments)[nparams + i].type, null, null, null); |
Line 1811 in 91adbef
| params.push(new Parameter(STC.in_, tn.arrayOf(), null, null, null)); |
I did a few tests and since those are mostly druntime calls, and scope is ignored, most seems harmless (although they could interfere with escape analysis), but those kinds of disparities will come back to bite us at some point.
|
And I shall again express my distaste for the double preview switch, as |
in mean scope const as originally plannedin mean scope const as originally planned
a079775 to
8881803
Compare
|
@Geod24 I ended up submitting this with a preview switch because that way nothing breaks. I went back to my original idea of making |
8881803 to
1bfe5f5
Compare
The problem with those is that they just keep growing and we haven't activated a single one in the last two (three?) years. I guess at some point D3 (or 202X) will be equal to a set of preview switches - though I guess that's the only option available :/ |
1bfe5f5 to
156a474
Compare
in mean scope const as originally plannedin mean scope const as originally planned
156a474 to
3b9b94a
Compare
|
One way is to have it on for the PR, and then fix everything that it breaks in all the tests. Once that's done, then put it behind a preview switch. I did something similar for #10812 except instead of a preview switch it printed deprecation messages. I don't see a way to do deprecations for this PR, so preview should be it. |
61a3523 to
6192c0f
Compare
12345swordy
left a comment
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.
Lets merge this for now, and start working on breakage that may cause from this.
|
Something that was overlooked: A changelog entry. |
|
Reboot of #10506