Turn array.sort and array.reverse into errors.#6554
Turn array.sort and array.reverse into errors.#6554quickfur wants to merge 1 commit intodlang:masterfrom
Conversation
|
I think you need to update a couple of tests: |
|
If we want go forward with this the tests have to be removed. |
|
Oops, forgot to run the tests before submitting the PR :D Will do that right now. |
|
Hmm. I'm not sure it's a good idea to just remove these tests. Should they be moved to phobos instead? |
Good idea! (assuming that Phobos |
|
Hmm. The dmd testsuite has stress tests that use |
What is so special about reverse? It's just a call to runtime library, any other call should do. |
|
The result of calling |
|
@wilzbach I'd say it would be a bug if Phobos |
Then it doesn't check anything other then that reverse is callable as runtime function and it's result is such and such. What is compiler stress-test about it? |
|
@DmitryOlshansky Honestly I've no idea. I'm just trying to get the testsuite to pass. :-D |
The simplest way is to actually admit they are no longer applicable and delete them ;) |
|
Haha, OK! |
|
Whoa, that file (test/runnable/stress.d) has tons of copy-pasta. Is this dating from before D had templates or what?! With today's language this file could easily be condensed to 10% of its size! |
Given the simple name I'd expect it to be as old as early D1 so no templates totally expected. Another point is that you don't want to complicate matters with templates as these have to be tested in the compiler as well. |
|
Bah... |
|
(Though I suppose I could just take out the |
|
Actually, |
| alias T3 = const ubyte[this.sizeof]; // ok <- error | ||
| } | ||
|
|
||
| /***************************************************/ |
There was a problem hiding this comment.
I deleted this test instead of importing std.algorithm, because bug 13481 is specific to built-in attributes, and now that .sort is gone, the bug no longer applies.
|
OK, updated the test suite, mostly just by importing Isn't it only in the compiler code itself that we're refraining from importing Phobos? The test suite should be exempt, right? |
|
compiler tests should not depend on phobos since then a change in Phobos
can cause dmd tests to break and that is very confusing.
2017-02-22 0:10 GMT+01:00 H. S. Teoh <notifications@github.com>:
… OK, updated the test suite, mostly just by importing std.algorithm. I'm
not sure where the idea came from that we're not allowed to use Phobos in
the test suite; I've seen at least a handful of places that explicitly
imports std.algorithm.
Isn't it only in the compiler code itself that we're refraining from
importing Phobos? The test suite should be exempt, right?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6554 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACtpCMujXv6VoacEn2i49xC--UM3OC4Kks5re270gaJpZM4MH53->
.
|
|
But what about the existing compiler tests that import Phobos? |
|
those should be reevaluated sometime. |
97551f2 to
977babe
Compare
test/runnable/foreach4.d
Outdated
| assert(a.array[1] == 82); | ||
|
|
||
| foreach (uint u; &a.reverse) | ||
| foreach (uint u; &a.forward) |
There was a problem hiding this comment.
Changed this to forward instead of reverse, because it seems that the idea was to test the uint index type, but the result of the operation is ignored. Besides, Phobos reverse does not return the array, so it can't be substituted here.
|
std.algorithm.sort and .reverse needs to be checked to see if the dmd tests are covered there. If so, delete the tests in dmd. If not, add the tests to the phobos unit tests, and delete them from dmd's tests. |
They should not be there, and their existence is not a reason to add more phobos imports. |
|
Fair enough, I'll move the tests to phobos instead. |
| arguments.push(e); | ||
| e = new CallExp(e.loc, ec, arguments); | ||
| e.type = next.arrayOf(); | ||
| error(e.loc, "use std.algorithm.reverse instead of .reverse property"); |
There was a problem hiding this comment.
Since this is a unique error message and not the generic "undefined identifier". Shouldn't there be a test for that, make sure it fails correctly?
There was a problem hiding this comment.
Ideally all diagnostics should have a fail test, yes.
| @@ -4542,103 +4542,23 @@ extern (C++) class TypeArray : TypeNext | |||
| } | |||
| if (ident == Id.reverse && (n.ty == Tchar || n.ty == Twchar)) | |||
There was a problem hiding this comment.
Are these the only places where Id.reverse and Id.sort are used?
Perhaps add a comment to set a future date for error -> gone.
There was a problem hiding this comment.
In fact, these first two branches can be removed, as the error is the same for both strings and arrays in this PR.
| import std.algorithm : sort; | ||
|
|
||
| void test45() | ||
| { |
There was a problem hiding this comment.
Put these imports inside the function scope.
|
@quickfur, can you please rebase? |
|
@MartinNowak has the time for this come? |
andralex
left a comment
There was a problem hiding this comment.
all involved, please let's take this home thx!
Continuing the deprecation process. After the next release, this code can be removed altogether and we will no longer need to invoke array.sort() with parentheses in order to get std.algorithm.sort.
|
Would somebody like to take over this PR? I currently don't have enough time to sort through the various tests in the testsuite to update them. The compiler code itself is finished, but some of the tests need to be moved to Phobos, some need to be reevaluated, etc.. |
205d4af to
1833371
Compare
|
P.S. I rebased the code on the latest git HEAD so it should be easy for somebody to take over now. |
|
cc @somzzz got time? |
|
@andralex I can take this one :) |
| e = new CallExp(e.loc, ec, arguments); | ||
| e.type = next.arrayOf(); | ||
| error(e.loc, "use std.algorithm.sort instead of .sort property"); | ||
| goto Lerror; |
There was a problem hiding this comment.
These first two branches can be removed, as the error is the same for both strings and arrays in this PR.
|
@andralex a few a tests are failing when we turn this into errors. |
|
e.g. we just throw an error that the property was not found. |
|
This was done in #6827 |
Continuing the deprecation process, as
array.sortandarray.reversehave been warnings / deprecations since before the C++ to D switchover in Aug 2015. It's high time we moved forward.After the next release, this code can be removed altogether and we will no longer need to invoke
array.sort()with the empty parentheses in order to getstd.algorithm.sort.