Reduce usage of scope that relied on issue 20150#254
Reduce usage of scope that relied on issue 20150#254atilaneves merged 1 commit intoatilaneves:masterfrom
scope that relied on issue 20150#254Conversation
Issue 20150 means that parameters on pure functions are assumed `scope` even when they could be returned or assigned to an object passed through a different parameter.
| * Verify that two values are the same. | ||
| * Throws: UnitTestException on failure | ||
| */ | ||
| void shouldEqual(V, E)(scope auto ref V value, scope auto ref E expected, string file = __FILE__, size_t line = __LINE__) |
There was a problem hiding this comment.
I don't see what's wrong with having scope here. Is it because value and expected may referenced from inside the the UnitTestException?
There was a problem hiding this comment.
It could still be inferred, but this functions calls formatValueInItsOwnLine on value which calls convertToString which might call value.toString which might not be scope.
|
|
||
|
|
||
| // Formats output in different lines | ||
| private string[] formatValueInItsOwnLine(T)(in string prefix, scope auto ref T value) { |
There was a problem hiding this comment.
in doesn't imply scope without -preview=in. I didn't want to add -preview=in to unit-threaded because that's an unapproved feature.
There was a problem hiding this comment.
Error: attribute
scopecannot be applied within, use-preview=ininstead
There was a problem hiding this comment.
Why remove
in?
I asked the same question. See above.
|
@atilaneves Can you approve or request changes? This is blocking a fix for a critical dip1000 issue in dmd. |
Needed to pass buildkite on dlang/dmd#12010
Sometimes
scopehad to be added (indoes not meanscopeyet), most of the time it had to be removed.It could still be inferred since they are template functions, but it's very fragile: a single call to a non-scope
toString()will make everything above it fail to bescope(and correctly so). This could be improved, but for now I'm focussed on making the accepts-invalid go away.