-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Fix Issue 20353 - -checkaction=context does not work well with const … #10535
Fix Issue 20353 - -checkaction=context does not work well with const … #10535
Conversation
|
Thanks for your pull request and interest in making D better, @MoonlightSentinel! 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 references
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#10535" |
c7c46d1 to
9a72dff
Compare
8b6cc65 to
6a2f6fc
Compare
|
The test fails for release builds but succeeds when the |
27f3370 to
ab4fc7b
Compare
ab4fc7b to
22f9ce3
Compare
eec8be5 to
a0cda2b
Compare
|
The delayed
CC @RazvanN7 EDIT: The spec refers to executing the |
a0cda2b to
27f105c
Compare
|
This should be good now (The failures are network timeouts) |
|
I'm not really convinced by this diff TBH. From what I see, this changes behavior so that constfolded expressions do not result in And the benefit of this is just a slightly better output. Now it seems that every asserts that would be affected by this bug could be turned into a void main() {
const x = -1L;
const y = -2L;
static assert(x == y);
}So, why not re-use this mechanism instead and provide the string directly from the compiler ? |
The example in the test is constfolded and treated as
Are you suggesting to implicitly promote |
% echo "void main () { const x = 1; const y = 42; assert(x == y); }" > pr10535.d
% dmd -release -run pr10535.d
Error: program killed by signal 4That being said, I just tested this PR and the
No, as that would break the usage of " |
I think my previous reply was worded poorly- the test case (not the
Thats could be an improvement but would require special-casing depending on the operands as I'm not entirely sure why your example even works but |
I was thinking of just providing a template overload that accepts a string. Can you add the following test case to your PR: struct Foo { int a; float b; }
static immutable Foo x, y;
void main ()
{
assert(x == y);
}For me this still print |
There is something missing here?
Done
NVM, the spec allows this rewrite |
54a372b to
dfe0418
Compare
dfe0418 to
574d8e3
Compare
574d8e3 to
65d10f7
Compare
Essentially this is a problem of the current implementation of The correct approach IMHO would be to apply Handling complex expressions would also suffice to handle such I tried to implement the first approach but was not successfull yet |
65d10f7 to
7f6cc50
Compare
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 think that the fix is fine. I have hit this problem in the past also where the optimizer kicks in way too early, before actual error checking is done, and by the time you want to print the error the AST has already been irreversibly altered.
|
This issue will probably be fixed by #11005 |
…numbers