Skip to content
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

SortedRange.opSlice() should be return scope #6866

Merged
merged 1 commit into from
Feb 17, 2019

Conversation

WalterBright
Copy link
Member

Progress to -dip1000 compatibility.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + phobos#6866"

@WalterBright
Copy link
Member Author

buildkite/phobos fails with:

generated/linux/release/64/unittest/test_runner rt.typeinfo.ti_wchar
--
  | generated/linux/release/64/unittest/test_runner etc.linux.memoryerror
  | 0.000s PASS release64 etc.linux.memoryerror
  | done
  | make[1]: Leaving directory '/var/lib/buildkite-agent/builds/ci-agent-8331da0f-b683-48a8-9b92-9391bb7a3ec9-7/dlang/phobos/druntime'
  | 🚨 Error: The command exited with status 2

What does that mean?

@WalterBright
Copy link
Member Author

Blocking dlang/dmd#9220

@wilzbach
Copy link
Member

No, the error is:

generated/linux/release/64/benchmark.o:benchmark/runbench.d:function _D3std5range__T11SortedRangeTAkVAyaa6_61203c3d2062ZQBk__T10lowerBoundVEQCrQCq12SearchPolicyi3TyiZQBoMFNaNbNiNfyiZSQEiQEh__TQEeTQDuVQDva6_61203c3d2062ZQFf: error: undefined reference to '_D3std5range__T11SortedRangeTAkVAyaa6_61203c3d2062ZQBk7opSliceMFNaNbNiNfmmZSQCwQCv__TQCsTQCiVQCja6_61203c3d2062ZQDt'
--
  | collect2: error: ld returned 1 exit status
  | Error: linker exited with status 1

We went throw this numerous times. scope breaks the binary compatibility and thus the linking fails.
The problem here is that on Buildkite the druntime benchmark target (which is not run on the auto-tester) doesn't recompile Phobos.

tl;dr: it's safe to merge (in terms of this particular Buildkite error)

@@ -10493,7 +10493,7 @@ if (isInputRange!Range && !isInstanceOf!(SortedRange, Range))

/// Ditto
static if (hasSlicing!Range)
auto opSlice(size_t a, size_t b)
auto opSlice(size_t a, size_t b) return scope @trusted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the compiler be able to infer the safety here automatically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's more, Range.opSlice might be unsafe. This can't be @trusted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's more, Range.opSlice might be unsafe. This can't be @trusted.

#6869

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this PR earlier and was confused by this as well. The opSlice being called could easily be exported by a range that I wrote, not even a range in Phobos.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not always able to, often due to circular references. Phobos is full of circular templates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding comments to the code with an explanation of why it's needed. If appropriate, the circumstances under which it could be removed. If it's a long explanation, add it to the PR and reference it from the code. Otherwise future readers of the code will be left wondering.

@wilzbach wilzbach merged commit 1fac010 into dlang:master Feb 17, 2019
@WalterBright WalterBright deleted the sorted-slice branch February 18, 2019 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants