Skip to content

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented May 12, 2018

This is also a followup to #8141

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JinShil!

Bugzilla references

Auto-close Bugzilla Severity Description
12228 normal Identifiers 'this' and 'super' should not be allowed as base classes

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 + dmd#8242"

@JinShil JinShil added the Review:WIP Work In Progress - not ready for review or pulling label May 12, 2018
@JinShil
Copy link
Contributor Author

JinShil commented May 13, 2018

@CyberShadow, can you please advise on why DAutoTest is failing while others are passing?

@CyberShadow
Copy link
Member

Could be due to a difference in the DMD version used to compile DMD (DAutoTest is trying to build the DMD source documentation at the point where it fails).

Does the error message make sense to you?

dmd/sapply.d(30): Error: typeof(super).visit is used as a type
dmd/nogc.d(32): Error: typeof(super).visit is used as a type
dmd/typesem.d(1513): Error: typeof(super).visit is used as a type
dmd/typesem.d(2059): Error: typeof(super).visit is used as a type
dmd/typesem.d(2562): Error: typeof(super).visit is used as a type
dmd/func.d(71): Error: typeof(super).visit is used as a type
dmd/apply.d(32): Error: typeof(super).visit is used as a type

If it's an easy fix, it might as well be done, to avoid unnecessarily restraining the range of versions that DMD can be built with.

@JinShil
Copy link
Contributor Author

JinShil commented May 13, 2018

Does the error message make sense to you?

Somewhat. I did modify those lines, but it appears that the compiler being used to build the documentation has a bug.

DAutoTest: HOST_DC=/home/dtest/DAutoTest/work/dl/dmd-2.067.1/dmd2/linux/bin64/dmd
auto-tester: HOST_DC=/home/braddr/sandbox/at-client/release-build/dmd-2.079.0/linux/bin64/dmd

So DAutoTest is using 2.067.1? Is that necessary? Can it be upgraded?

//printf("TypeIdentifier::resolve(sc = %p, idents = '%s')\n", sc, mt.toChars());
if ((mt.ident.equals(Id._super) || mt.ident.equals(Id.This)) && !hasThis(sc))
{
// @@@DEPRECATED_2019-05@@@.
Copy link
Contributor

Choose a reason for hiding this comment

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

The new deprecation DIP suggests to use versions instead.

@CyberShadow
Copy link
Member

I'm looking into this.

BTW, any plans to deprecate/remove calling static methods via instances? Or at least opCall... I was bitten by this just yesterday, trying to wrap a class that had a non-static opCall.

@JinShil
Copy link
Contributor Author

JinShil commented May 13, 2018

BTW, any plans to deprecate/remove calling static methods via instances?

Is there an bug/issue report?

@CyberShadow
Copy link
Member

Sorry, I don't know. It's a very long standing pain point (since D 1.x).

@JinShil
Copy link
Contributor Author

JinShil commented May 13, 2018

Sorry, I don't know. It's a very long standing pain point (since D 1.x).

File a bug report, get @WalterBright or @andralex to approve it, and if I can understand it and it's within my ability, I'll implement it.

@CyberShadow
Copy link
Member

Found the issue.

DAutoTest and related software will use 2.079.0 once #8112 is merged (see #8112 (comment)). However, that PR is still not merged, so the old default (2.067.1) remains in force.

There are a few ways to proceed:

  • Wait until needed compiler features to convert backend to D #8112 is merged
  • Work around the compiler bug by adjusting the code in this PR
  • Add a second condition for detecting when a newer compiler is needed to ae.sys.d.manager to allow the code as it is in this PR right now to compile in Digger and DAutoTest.

I would obviously prefer one of the first two :)

@wilzbach
Copy link
Contributor

deprecate/remove calling static methods via instances?

AFAICT that's a feature by design. I at least remember Walter defending this a few months ago as it allows for more generic code.

Or at least opCall

Not sure even this will be easy.
It's still used in Phobos: https://github.com/dlang/phobos/search?utf8=✓&q="static+opcall"&type=

@CyberShadow
Copy link
Member

CyberShadow commented May 13, 2018

Being able to forbid non-static calls in a contract would work too.

@JinShil JinShil added Merge:Blocked and removed Review:WIP Work In Progress - not ready for review or pulling labels May 13, 2018
@JinShil
Copy link
Contributor Author

JinShil commented May 13, 2018

Will wait on #8112 or alternative.

@JinShil JinShil changed the title Issue 12228 - Deprecate usage of 'this' and 'super' as types Issue 12228 & 13943 - Deprecate usage of 'this' and 'super' as types May 14, 2018
@JinShil JinShil changed the title Issue 12228 & 13943 - Deprecate usage of 'this' and 'super' as types Issue 12228 & Issue 13943 - Deprecate usage of 'this' and 'super' as types May 14, 2018
@WalterBright
Copy link
Member

AFAICT that's a feature by design. I at least remember Walter defending this a few months ago as it allows for more generic code.

Yes, it's deliberate. Removing it would require a compelling argument.

@CyberShadow
Copy link
Member

CyberShadow commented May 21, 2018

Removing it would require a compelling argument.

The reason I asked is that I ran into a problem caused by it when trying to implement reference-counted classes.

The problem occurs when the wrapped class defines opCall. In this case, we cannot use static opCall in the reference-counted wrapper to wrap the class constructor (and we can't use normal struct constructors because this() without parameters is forbidden on structs).

In the end I had to move all construction to factory functions because of this issue.

Do you know a better solution?

@JinShil
Copy link
Contributor Author

JinShil commented May 31, 2018

DAutoTest has been updated. This PR is ready to go.

@Geod24
Copy link
Member

Geod24 commented Jun 12, 2018

There's a slight problem with this: https://issues.dlang.org/show_bug.cgi?id=18976

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.

7 participants