-
-
Notifications
You must be signed in to change notification settings - Fork 664
Implement Static Single Assignment (SSA) DIP #22171
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request, @WalterBright! 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#22171" |
| { | ||
| final int i = 3; | ||
| const ref r = i; | ||
| const(int)*p = &i; |
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.
static assert(is(typeof(&i)) == const(int)*));
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.
DIP says 'final does not affect the type'. Interestingly, *[&i][0] = 5; gives an error:
finalvar.d(9): Error: cannot implicitly convert final `& i` to `int*`
*[&i][0] = 5;
^
Would be good to add something like that to the test.
|
Given that this is running up against existing test cases (failing), it'll need to go behind a preview switch until it's ready & approved. |
|
Ran into an unexpected problem. Using |
|
I think I can fix it. Tomorrow! |
void main()
{
final int[2] a;
a[0]++; // no error
final S s;
s.i++; // no error
}
struct S
{
int i;
}The DIP says:
It doesn't mention static arrays, but as they are values, the elements should be final IMO. |
|
@ntrel you're right |
244704b to
e22d4a7
Compare
|
Casting a pointer to final should probably be allowed in final int i = 3;
int* pm = cast(int*) &i; // Error: cannot implicitly convert final `& i` to `int*` |
|
As |
|
|
How does final interact with other types and storage classes? Structs, arrays, noreturn, ref, etc. |
All in the same way. Any
|
I'm amending that to 'final' being applied to an |
|
The behavior of all these cases is based on the idea that a final object should not be subject to modification after initialization. |
1ad6764 to
5c46e7c
Compare
When I tried this a few days ago, the final actually applied to the pointed-to data, and I think that is more useful. See https://forum.dlang.org/post/[email protected]. |
|
@ntrel thanks I will look into that. |
95ef9e5 to
93ae869
Compare
|
As explained in the ng, I've put this on hold for the time being. |
https://github.com/WalterBright/documents/blob/master/final.md